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

Unified 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: Final version. 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 side-by-side diff with in-line comments
Download patch
Index: google_apis/gaia/gaia_auth_fetcher.cc
diff --git a/google_apis/gaia/gaia_auth_fetcher.cc b/google_apis/gaia/gaia_auth_fetcher.cc
index a79a0fc8863c9c0ebe36ecfe5634d2dc54a0030e..884a295da4d3db6f12a58fabae82a5d709b64122 100644
--- a/google_apis/gaia/gaia_auth_fetcher.cc
+++ b/google_apis/gaia/gaia_auth_fetcher.cc
@@ -115,6 +115,9 @@ const char GaiaAuthFetcher::kOAuth2CodeToTokenPairBodyFormat[] =
"client_secret=%s&"
"code=%s";
// static
+const char GaiaAuthFetcher::kOAuth2CodeToTokenPairDeviceIdParam[] =
+ "device_id=%s&device_type=chrome";
+// static
const char GaiaAuthFetcher::kOAuth2RevokeTokenBodyFormat[] =
"token=%s";
// static
@@ -341,7 +344,8 @@ std::string GaiaAuthFetcher::MakeGetAuthCodeBody(bool include_device_type) {
// static
std::string GaiaAuthFetcher::MakeGetTokenPairBody(
- const std::string& auth_code) {
+ const std::string& auth_code,
+ const std::string& device_id) {
std::string encoded_scope = net::EscapeUrlEncodedData(
GaiaConstants::kOAuth1LoginScope, true);
std::string encoded_client_id = net::EscapeUrlEncodedData(
@@ -349,11 +353,14 @@ std::string GaiaAuthFetcher::MakeGetTokenPairBody(
std::string encoded_client_secret = net::EscapeUrlEncodedData(
GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), true);
std::string encoded_auth_code = net::EscapeUrlEncodedData(auth_code, true);
- return base::StringPrintf(kOAuth2CodeToTokenPairBodyFormat,
- encoded_scope.c_str(),
- encoded_client_id.c_str(),
- encoded_client_secret.c_str(),
- encoded_auth_code.c_str());
+ std::string body = base::StringPrintf(
+ kOAuth2CodeToTokenPairBodyFormat, encoded_scope.c_str(),
+ encoded_client_id.c_str(), encoded_client_secret.c_str(),
+ encoded_auth_code.c_str());
+ if (!device_id.empty())
achuithb 2015/05/12 23:25:01 nit: Believe you need {} here?
dzhioev (left Google) 2015/05/13 00:25:18 Done.
+ body += "&" + base::StringPrintf(kOAuth2CodeToTokenPairDeviceIdParam,
+ device_id.c_str());
+ return body;
}
// static
@@ -678,10 +685,16 @@ void GaiaAuthFetcher::StartCookieForOAuthLoginTokenExchangeWithDeviceId(
void GaiaAuthFetcher::StartAuthCodeForOAuth2TokenExchange(
const std::string& auth_code) {
+ StartAuthCodeForOAuth2TokenExchangeWithDeviceId(auth_code, std::string());
+}
+
+void GaiaAuthFetcher::StartAuthCodeForOAuth2TokenExchangeWithDeviceId(
+ const std::string& auth_code,
+ const std::string& device_id) {
DCHECK(!fetch_pending_) << "Tried to fetch two things at once!";
DVLOG(1) << "Starting OAuth token pair fetch";
- request_body_ = MakeGetTokenPairBody(auth_code);
+ request_body_ = MakeGetTokenPairBody(auth_code, device_id);
fetcher_ =
CreateGaiaFetcher(getter_, request_body_, std::string(),
oauth2_token_gurl_, kLoadFlagsIgnoreCookies, this);
« components/user_manager/user_manager_base.cc ('K') | « 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