Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Side by Side Diff: google_apis/gaia/gaia_oauth_client.cc

Issue 993103002: Add tokeninfo call with token identified by token_handle parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « google_apis/gaia/gaia_oauth_client.h ('k') | google_apis/gaia/gaia_oauth_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "google_apis/gaia/gaia_oauth_client.h" 5 #include "google_apis/gaia/gaia_oauth_client.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 GaiaOAuthClient::Delegate* delegate); 52 GaiaOAuthClient::Delegate* delegate);
53 void GetUserEmail(const std::string& oauth_access_token, 53 void GetUserEmail(const std::string& oauth_access_token,
54 int max_retries, 54 int max_retries,
55 Delegate* delegate); 55 Delegate* delegate);
56 void GetUserId(const std::string& oauth_access_token, 56 void GetUserId(const std::string& oauth_access_token,
57 int max_retries, 57 int max_retries,
58 Delegate* delegate); 58 Delegate* delegate);
59 void GetUserInfo(const std::string& oauth_access_token, 59 void GetUserInfo(const std::string& oauth_access_token,
60 int max_retries, 60 int max_retries,
61 Delegate* delegate); 61 Delegate* delegate);
62 void GetTokenInfo(const std::string& oauth_access_token, 62 void GetTokenInfo(const std::string& qualifier,
63 const std::string& query,
63 int max_retries, 64 int max_retries,
64 Delegate* delegate); 65 Delegate* delegate);
65 66
66 // net::URLFetcherDelegate implementation. 67 // net::URLFetcherDelegate implementation.
67 void OnURLFetchComplete(const net::URLFetcher* source) override; 68 void OnURLFetchComplete(const net::URLFetcher* source) override;
68 69
69 private: 70 private:
70 friend class base::RefCountedThreadSafe<Core>; 71 friend class base::RefCountedThreadSafe<Core>;
71 72
72 enum RequestType { 73 enum RequestType {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 net::LOAD_DO_NOT_SAVE_COOKIES); 183 net::LOAD_DO_NOT_SAVE_COOKIES);
183 184
184 // Fetchers are sometimes cancelled because a network change was detected, 185 // Fetchers are sometimes cancelled because a network change was detected,
185 // especially at startup and after sign-in on ChromeOS. Retrying once should 186 // especially at startup and after sign-in on ChromeOS. Retrying once should
186 // be enough in those cases; let the fetcher retry up to 3 times just in case. 187 // be enough in those cases; let the fetcher retry up to 3 times just in case.
187 // http://crbug.com/163710 188 // http://crbug.com/163710
188 request_->SetAutomaticallyRetryOnNetworkChanges(3); 189 request_->SetAutomaticallyRetryOnNetworkChanges(3);
189 request_->Start(); 190 request_->Start();
190 } 191 }
191 192
192 void GaiaOAuthClient::Core::GetTokenInfo(const std::string& oauth_access_token, 193 void GaiaOAuthClient::Core::GetTokenInfo(const std::string& qualifier,
194 const std::string& query,
193 int max_retries, 195 int max_retries,
194 Delegate* delegate) { 196 Delegate* delegate) {
195 DCHECK_EQ(request_type_, NO_PENDING_REQUEST); 197 DCHECK_EQ(request_type_, NO_PENDING_REQUEST);
196 DCHECK(!request_.get()); 198 DCHECK(!request_.get());
197 request_type_ = TOKEN_INFO; 199 request_type_ = TOKEN_INFO;
198 std::string post_body = 200 std::string post_body =
199 "access_token=" + net::EscapeUrlEncodedData(oauth_access_token, true); 201 qualifier + "=" + net::EscapeUrlEncodedData(query, true);
200 MakeGaiaRequest(GURL(GaiaUrls::GetInstance()->oauth2_token_info_url()), 202 MakeGaiaRequest(GURL(GaiaUrls::GetInstance()->oauth2_token_info_url()),
201 post_body, 203 post_body,
202 max_retries, 204 max_retries,
203 delegate); 205 delegate);
204 } 206 }
205 207
206 void GaiaOAuthClient::Core::MakeGaiaRequest( 208 void GaiaOAuthClient::Core::MakeGaiaRequest(
207 const GURL& url, 209 const GURL& url,
208 const std::string& post_body, 210 const std::string& post_body,
209 int max_retries, 211 int max_retries,
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 391
390 void GaiaOAuthClient::GetUserInfo(const std::string& access_token, 392 void GaiaOAuthClient::GetUserInfo(const std::string& access_token,
391 int max_retries, 393 int max_retries,
392 Delegate* delegate) { 394 Delegate* delegate) {
393 return core_->GetUserInfo(access_token, max_retries, delegate); 395 return core_->GetUserInfo(access_token, max_retries, delegate);
394 } 396 }
395 397
396 void GaiaOAuthClient::GetTokenInfo(const std::string& access_token, 398 void GaiaOAuthClient::GetTokenInfo(const std::string& access_token,
397 int max_retries, 399 int max_retries,
398 Delegate* delegate) { 400 Delegate* delegate) {
399 return core_->GetTokenInfo(access_token, max_retries, delegate); 401 return core_->GetTokenInfo("access_token", access_token, max_retries,
402 delegate);
403 }
404
405 void GaiaOAuthClient::GetTokenHandleInfo(const std::string& token_handle,
406 int max_retries,
407 Delegate* delegate) {
408 return core_->GetTokenInfo("token_handle", token_handle, max_retries,
409 delegate);
400 } 410 }
401 411
402 } // namespace gaia 412 } // namespace gaia
OLDNEW
« no previous file with comments | « google_apis/gaia/gaia_oauth_client.h ('k') | google_apis/gaia/gaia_oauth_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698