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

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

Issue 1138143002: Pass Device ID in the oauth2/token request. Keep Device ID in local state on Chrome OS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment. Created 5 years, 7 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_auth_fetcher.h ('k') | no next file » | 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_auth_fetcher.h" 5 #include "google_apis/gaia/gaia_auth_fetcher.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 const char GaiaAuthFetcher::kClientLoginToOAuth2WithDeviceTypeBodyFormat[] = 108 const char GaiaAuthFetcher::kClientLoginToOAuth2WithDeviceTypeBodyFormat[] =
109 "scope=%s&client_id=%s&device_type=chrome"; 109 "scope=%s&client_id=%s&device_type=chrome";
110 // static 110 // static
111 const char GaiaAuthFetcher::kOAuth2CodeToTokenPairBodyFormat[] = 111 const char GaiaAuthFetcher::kOAuth2CodeToTokenPairBodyFormat[] =
112 "scope=%s&" 112 "scope=%s&"
113 "grant_type=authorization_code&" 113 "grant_type=authorization_code&"
114 "client_id=%s&" 114 "client_id=%s&"
115 "client_secret=%s&" 115 "client_secret=%s&"
116 "code=%s"; 116 "code=%s";
117 // static 117 // static
118 const char GaiaAuthFetcher::kOAuth2CodeToTokenPairDeviceIdParam[] =
119 "device_id=%s&device_type=chrome";
120 // static
118 const char GaiaAuthFetcher::kOAuth2RevokeTokenBodyFormat[] = 121 const char GaiaAuthFetcher::kOAuth2RevokeTokenBodyFormat[] =
119 "token=%s"; 122 "token=%s";
120 // static 123 // static
121 const char GaiaAuthFetcher::kGetUserInfoFormat[] = 124 const char GaiaAuthFetcher::kGetUserInfoFormat[] =
122 "LSID=%s"; 125 "LSID=%s";
123 // static 126 // static
124 const char GaiaAuthFetcher::kMergeSessionFormat[] = 127 const char GaiaAuthFetcher::kMergeSessionFormat[] =
125 "uberauth=%s&" 128 "uberauth=%s&"
126 "continue=%s&" 129 "continue=%s&"
127 "source=%s"; 130 "source=%s";
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 encoded_client_id.c_str()); 337 encoded_client_id.c_str());
335 } else { 338 } else {
336 return base::StringPrintf(kClientLoginToOAuth2BodyFormat, 339 return base::StringPrintf(kClientLoginToOAuth2BodyFormat,
337 encoded_scope.c_str(), 340 encoded_scope.c_str(),
338 encoded_client_id.c_str()); 341 encoded_client_id.c_str());
339 } 342 }
340 } 343 }
341 344
342 // static 345 // static
343 std::string GaiaAuthFetcher::MakeGetTokenPairBody( 346 std::string GaiaAuthFetcher::MakeGetTokenPairBody(
344 const std::string& auth_code) { 347 const std::string& auth_code,
348 const std::string& device_id) {
345 std::string encoded_scope = net::EscapeUrlEncodedData( 349 std::string encoded_scope = net::EscapeUrlEncodedData(
346 GaiaConstants::kOAuth1LoginScope, true); 350 GaiaConstants::kOAuth1LoginScope, true);
347 std::string encoded_client_id = net::EscapeUrlEncodedData( 351 std::string encoded_client_id = net::EscapeUrlEncodedData(
348 GaiaUrls::GetInstance()->oauth2_chrome_client_id(), true); 352 GaiaUrls::GetInstance()->oauth2_chrome_client_id(), true);
349 std::string encoded_client_secret = net::EscapeUrlEncodedData( 353 std::string encoded_client_secret = net::EscapeUrlEncodedData(
350 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), true); 354 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), true);
351 std::string encoded_auth_code = net::EscapeUrlEncodedData(auth_code, true); 355 std::string encoded_auth_code = net::EscapeUrlEncodedData(auth_code, true);
352 return base::StringPrintf(kOAuth2CodeToTokenPairBodyFormat, 356 std::string body = base::StringPrintf(
353 encoded_scope.c_str(), 357 kOAuth2CodeToTokenPairBodyFormat, encoded_scope.c_str(),
354 encoded_client_id.c_str(), 358 encoded_client_id.c_str(), encoded_client_secret.c_str(),
355 encoded_client_secret.c_str(), 359 encoded_auth_code.c_str());
356 encoded_auth_code.c_str()); 360 if (!device_id.empty()) {
361 body += "&" + base::StringPrintf(kOAuth2CodeToTokenPairDeviceIdParam,
362 device_id.c_str());
363 }
364 return body;
357 } 365 }
358 366
359 // static 367 // static
360 std::string GaiaAuthFetcher::MakeRevokeTokenBody( 368 std::string GaiaAuthFetcher::MakeRevokeTokenBody(
361 const std::string& auth_token) { 369 const std::string& auth_token) {
362 return base::StringPrintf(kOAuth2RevokeTokenBodyFormat, auth_token.c_str()); 370 return base::StringPrintf(kOAuth2RevokeTokenBodyFormat, auth_token.c_str());
363 } 371 }
364 372
365 // static 373 // static
366 std::string GaiaAuthFetcher::MakeGetUserInfoBody(const std::string& lsid) { 374 std::string GaiaAuthFetcher::MakeGetUserInfoBody(const std::string& lsid) {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 679
672 fetcher_ = 680 fetcher_ =
673 CreateGaiaFetcher(getter_, request_body_, device_id_header, 681 CreateGaiaFetcher(getter_, request_body_, device_id_header,
674 client_login_to_oauth2_gurl_, net::LOAD_NORMAL, this); 682 client_login_to_oauth2_gurl_, net::LOAD_NORMAL, this);
675 fetch_pending_ = true; 683 fetch_pending_ = true;
676 fetcher_->Start(); 684 fetcher_->Start();
677 } 685 }
678 686
679 void GaiaAuthFetcher::StartAuthCodeForOAuth2TokenExchange( 687 void GaiaAuthFetcher::StartAuthCodeForOAuth2TokenExchange(
680 const std::string& auth_code) { 688 const std::string& auth_code) {
689 StartAuthCodeForOAuth2TokenExchangeWithDeviceId(auth_code, std::string());
690 }
691
692 void GaiaAuthFetcher::StartAuthCodeForOAuth2TokenExchangeWithDeviceId(
693 const std::string& auth_code,
694 const std::string& device_id) {
681 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; 695 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!";
682 696
683 DVLOG(1) << "Starting OAuth token pair fetch"; 697 DVLOG(1) << "Starting OAuth token pair fetch";
684 request_body_ = MakeGetTokenPairBody(auth_code); 698 request_body_ = MakeGetTokenPairBody(auth_code, device_id);
685 fetcher_ = 699 fetcher_ =
686 CreateGaiaFetcher(getter_, request_body_, std::string(), 700 CreateGaiaFetcher(getter_, request_body_, std::string(),
687 oauth2_token_gurl_, kLoadFlagsIgnoreCookies, this); 701 oauth2_token_gurl_, kLoadFlagsIgnoreCookies, this);
688 fetch_pending_ = true; 702 fetch_pending_ = true;
689 fetcher_->Start(); 703 fetcher_->Start();
690 } 704 }
691 705
692 void GaiaAuthFetcher::StartGetUserInfo(const std::string& lsid) { 706 void GaiaAuthFetcher::StartGetUserInfo(const std::string& lsid) {
693 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; 707 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!";
694 708
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 return alleged_error.find(kSecondFactor) != 1120 return alleged_error.find(kSecondFactor) !=
1107 std::string::npos; 1121 std::string::npos;
1108 } 1122 }
1109 1123
1110 // static 1124 // static
1111 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess( 1125 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess(
1112 const std::string& alleged_error) { 1126 const std::string& alleged_error) {
1113 return alleged_error.find(kWebLoginRequired) != 1127 return alleged_error.find(kWebLoginRequired) !=
1114 std::string::npos; 1128 std::string::npos;
1115 } 1129 }
OLDNEW
« no previous file with comments | « google_apis/gaia/gaia_auth_fetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698