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 15aa78a1d735641c77a60a648f8395ae9fa06261..c8391af22c8855ff7f03293cd0a260c892205802 100644 |
--- a/google_apis/gaia/gaia_auth_fetcher.cc |
+++ b/google_apis/gaia/gaia_auth_fetcher.cc |
@@ -135,13 +135,6 @@ const char GaiaAuthFetcher::kCaptchaUrlParam[] = "CaptchaUrl"; |
const char GaiaAuthFetcher::kCaptchaTokenParam[] = "CaptchaToken"; |
// static |
-const char GaiaAuthFetcher::kNeedsAdditional[] = "NeedsAdditional"; |
-// static |
-const char GaiaAuthFetcher::kCaptcha[] = "Captcha"; |
-// static |
-const char GaiaAuthFetcher::kTwoFactor[] = "TwoStep"; |
- |
-// static |
const char GaiaAuthFetcher::kCookiePersistence[] = "true"; |
// static |
// TODO(johnnyg): When hosted accounts are supported by sync, |
@@ -188,7 +181,6 @@ GaiaAuthFetcher::GaiaAuthFetcher(GaiaAuthConsumer* consumer, |
merge_session_gurl_(GaiaUrls::GetInstance()->merge_session_url()), |
uberauth_token_gurl_(base::StringPrintf(kUberAuthTokenURLFormat, |
GaiaUrls::GetInstance()->oauth1_login_url().c_str(), source.c_str())), |
- client_oauth_gurl_(GaiaUrls::GetInstance()->client_oauth_url()), |
oauth_login_gurl_(GaiaUrls::GetInstance()->oauth1_login_url()), |
client_login_to_oauth2_gurl_( |
GaiaUrls::GetInstance()->client_login_to_oauth2_url()), |
@@ -396,66 +388,6 @@ void GaiaAuthFetcher::ParseClientLoginResponse(const std::string& data, |
} |
// static |
-std::string GaiaAuthFetcher::MakeClientOAuthBody( |
- const std::string& username, |
- const std::string& password, |
- const std::vector<std::string>& scopes, |
- const std::string& persistent_id, |
- const std::string& friendly_name, |
- const std::string& locale) { |
- scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
- dict->SetString(GaiaConstants::kClientOAuthEmailKey, username); |
- dict->SetString(GaiaConstants::kClientOAuthPasswordKey, password); |
- |
- scoped_ptr<base::ListValue> scope_list(new base::ListValue); |
- for (size_t i = 0; i < scopes.size(); ++i) |
- scope_list->Append(base::Value::CreateStringValue(scopes[i])); |
- dict->Set(GaiaConstants::kClientOAuthScopesKey, scope_list.release()); |
- |
- dict->SetString(GaiaConstants::kClientOAuthOAuth2ClientIdKey, |
- GaiaUrls::GetInstance()->oauth2_chrome_client_id()); |
- // crbug.com/129600: use a less generic friendly name. |
- dict->SetString(GaiaConstants::kClientOAuthFriendlyDeviceNameKey, |
- friendly_name); |
- |
- scoped_ptr<base::ListValue> accepts_challenge_list(new base::ListValue); |
- accepts_challenge_list->Append(base::Value::CreateStringValue(kCaptcha)); |
- accepts_challenge_list->Append(base::Value::CreateStringValue(kTwoFactor)); |
- dict->Set(GaiaConstants::kClientOAuthAcceptsChallengesKey, |
- accepts_challenge_list.release()); |
- |
- dict->SetString(GaiaConstants::kClientOAuthLocaleKey, locale); |
- // Chrome presently does not not support a web-fallback for ClientOAuth, |
- // but need to hardcode an arbitrary one here since the endpoint expects it. |
- dict->SetString(GaiaConstants::kClientOAuthFallbackNameKey, "GetOAuth2Token"); |
- |
- std::string json_string; |
- base::JSONWriter::Write(dict.get(), &json_string); |
- return json_string; |
-} |
- |
-// static |
-std::string GaiaAuthFetcher::MakeClientOAuthChallengeResponseBody( |
- const std::string& name, |
- const std::string& token, |
- const std::string& solution) { |
- scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
- std::string field_name = name == kTwoFactor ? "otp" : "solution"; |
- |
- scoped_ptr<base::DictionaryValue> challenge_reply(new base::DictionaryValue); |
- challenge_reply->SetString(GaiaConstants::kClientOAuthNameKey, name); |
- challenge_reply->SetString(GaiaConstants::kClientOAuthChallengeTokenKey, |
- token); |
- challenge_reply->SetString(field_name, solution); |
- dict->Set(GaiaConstants::kClientOAuthchallengeReplyKey, |
- challenge_reply.release()); |
- |
- std::string json_string; |
- base::JSONWriter::Write(dict.get(), &json_string); |
- return json_string; |
-} |
- |
-// static |
std::string GaiaAuthFetcher::MakeOAuthLoginBody(const std::string& service, |
const std::string& source) { |
std::string encoded_service = net::EscapeUrlEncodedData(service, true); |
@@ -528,71 +460,6 @@ bool GaiaAuthFetcher::ParseClientLoginToOAuth2Cookie(const std::string& cookie, |
return false; |
} |
-// static |
-GoogleServiceAuthError |
-GaiaAuthFetcher::GenerateClientOAuthError(const std::string& data, |
- const net::URLRequestStatus& status) { |
- scoped_ptr<base::Value> value(base::JSONReader::Read(data)); |
- if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) |
- return GenerateAuthError(data, status); |
- DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); |
- |
- std::string cause; |
- if (!dict->GetStringWithoutPathExpansion("cause", &cause)) |
- return GoogleServiceAuthError::FromClientOAuthError(data); |
- |
- if (cause != kNeedsAdditional) |
- return GoogleServiceAuthError::FromClientOAuthError(data); |
- |
- DictionaryValue* challenge; |
- if (!dict->GetDictionaryWithoutPathExpansion("challenge", &challenge)) |
- return GoogleServiceAuthError::FromClientOAuthError(data); |
- |
- std::string name; |
- if (!challenge->GetStringWithoutPathExpansion("name", &name)) |
- return GoogleServiceAuthError::FromClientOAuthError(data); |
- |
- if (name == kCaptcha) { |
- std::string token; |
- std::string audio_url; |
- std::string image_url; |
- int image_width; |
- int image_height; |
- if (!challenge->GetStringWithoutPathExpansion("challenge_token", &token) || |
- !challenge->GetStringWithoutPathExpansion("audio_url", &audio_url) || |
- !challenge->GetStringWithoutPathExpansion("image_url", &image_url) || |
- !challenge->GetIntegerWithoutPathExpansion("image_width", |
- &image_width) || |
- !challenge->GetIntegerWithoutPathExpansion("image_height", |
- &image_height)) { |
- return GoogleServiceAuthError::FromClientOAuthError(data); |
- } |
- return GoogleServiceAuthError::FromCaptchaChallenge(token, GURL(audio_url), |
- GURL(image_url), |
- image_width, |
- image_height); |
- } else if (name == kTwoFactor) { |
- std::string token; |
- std::string prompt_text; |
- std::string alternate_text; |
- int field_length; |
- |
- // The protocol doc says these are required, but in practice they are not |
- // returned. So only a missing challenge token will cause an error here. |
- challenge->GetStringWithoutPathExpansion("prompt_text", &prompt_text); |
- challenge->GetStringWithoutPathExpansion("alternate_text", &alternate_text); |
- challenge->GetIntegerWithoutPathExpansion("field_length", &field_length); |
- if (!challenge->GetStringWithoutPathExpansion("challenge_token", &token)) |
- return GoogleServiceAuthError::FromClientOAuthError(data); |
- |
- return GoogleServiceAuthError::FromSecondFactorChallenge(token, prompt_text, |
- alternate_text, |
- field_length); |
- } |
- |
- return GoogleServiceAuthError::FromClientOAuthError(data); |
-} |
- |
void GaiaAuthFetcher::StartClientLogin( |
const std::string& username, |
const std::string& password, |
@@ -774,54 +641,6 @@ void GaiaAuthFetcher::StartTokenFetchForUberAuthExchange( |
fetcher_->Start(); |
} |
-void GaiaAuthFetcher::StartClientOAuth(const std::string& username, |
- const std::string& password, |
- const std::vector<std::string>& scopes, |
- const std::string& persistent_id, |
- const std::string& locale) { |
- DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; |
- |
- request_body_ = MakeClientOAuthBody(username, password, scopes, persistent_id, |
- source_, locale); |
- fetcher_.reset(CreateGaiaFetcher(getter_, |
- request_body_, |
- std::string(), |
- client_oauth_gurl_, |
- kLoadFlagsIgnoreCookies, |
- this)); |
- fetch_pending_ = true; |
- fetcher_->Start(); |
-} |
- |
-void GaiaAuthFetcher::StartClientOAuthChallengeResponse( |
- GoogleServiceAuthError::State type, |
- const std::string& token, |
- const std::string& solution) { |
- DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; |
- |
- std::string name; |
- switch (type) { |
- case GoogleServiceAuthError::CAPTCHA_REQUIRED: |
- name = kCaptcha; |
- break; |
- case GoogleServiceAuthError::TWO_FACTOR: |
- name = kTwoFactor; |
- break; |
- default: |
- NOTREACHED(); |
- } |
- |
- request_body_ = MakeClientOAuthChallengeResponseBody(name, token, solution); |
- fetcher_.reset(CreateGaiaFetcher(getter_, |
- request_body_, |
- std::string(), |
- client_oauth_gurl_, |
- kLoadFlagsIgnoreCookies, |
- this)); |
- fetch_pending_ = true; |
- fetcher_->Start(); |
-} |
- |
void GaiaAuthFetcher::StartOAuthLogin(const std::string& access_token, |
const std::string& service) { |
DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; |
@@ -1061,41 +880,6 @@ void GaiaAuthFetcher::OnUberAuthTokenFetch(const std::string& data, |
} |
} |
-void GaiaAuthFetcher::OnClientOAuthFetched(const std::string& data, |
- const net::URLRequestStatus& status, |
- int response_code) { |
- std::string refresh_token; |
- std::string access_token; |
- int expires_in_secs = 0; |
- |
- bool success = false; |
- if (status.is_success() && response_code == net::HTTP_OK) { |
- scoped_ptr<base::Value> value(base::JSONReader::Read(data)); |
- if (value.get() && value->GetType() == base::Value::TYPE_DICTIONARY) { |
- DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); |
- DictionaryValue* dict_oauth2; |
- if (dict->GetDictionaryWithoutPathExpansion("oauth2", &dict_oauth2)) { |
- success = ExtractOAuth2TokenPairResponse(dict_oauth2, &refresh_token, |
- &access_token, |
- &expires_in_secs); |
- } |
- } |
- } |
- |
- // TODO(rogerta): for now this reuses the OnOAuthLoginTokenXXX callbacks |
- // since the data is exactly the same. This ignores the optional |
- // persistent_id data in the response, which we may need to handle. |
- // If we do, we'll need to modify ExtractOAuth2TokenPairResponse() to parse |
- // the optional data and declare new consumer callbacks to take it. |
- if (success) { |
- consumer_->OnClientOAuthSuccess( |
- GaiaAuthConsumer::ClientOAuthResult(refresh_token, access_token, |
- expires_in_secs)); |
- } else { |
- consumer_->OnClientOAuthFailure(GenerateClientOAuthError(data, status)); |
- } |
-} |
- |
void GaiaAuthFetcher::OnOAuthLoginFetched(const std::string& data, |
const net::URLRequestStatus& status, |
int response_code) { |
@@ -1147,8 +931,6 @@ void GaiaAuthFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
OnMergeSessionFetched(data, status, response_code); |
} else if (url == uberauth_token_gurl_) { |
OnUberAuthTokenFetch(data, status, response_code); |
- } else if (url == client_oauth_gurl_) { |
- OnClientOAuthFetched(data, status, response_code); |
} else if (url == oauth_login_gurl_) { |
OnOAuthLoginFetched(data, status, response_code); |
} else if (url == oauth2_revoke_gurl_) { |