diff options
author | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-25 05:11:39 +0000 |
---|---|---|
committer | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-25 05:11:39 +0000 |
commit | 0b9b8afe9a9f8b58c9d2d07fb72b03497bb580d3 (patch) | |
tree | e1d24357a2cc41818cc6b805ab62bca15673c19f /google_apis | |
parent | 2dd893494aa3941b27aeaae21fb01b8fe688797b (diff) | |
download | chromium_src-0b9b8afe9a9f8b58c9d2d07fb72b03497bb580d3.zip chromium_src-0b9b8afe9a9f8b58c9d2d07fb72b03497bb580d3.tar.gz chromium_src-0b9b8afe9a9f8b58c9d2d07fb72b03497bb580d3.tar.bz2 |
Support for auth code based authentication flow for both app and web UI driven flow.
BUG=181008
TEST=experiments that are in progress
TBR=sky
Review URL: https://chromiumcodereview.appspot.com/12704002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190338 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/gaia/gaia_auth_fetcher.cc | 33 | ||||
-rw-r--r-- | google_apis/gaia/gaia_auth_fetcher.h | 9 |
2 files changed, 24 insertions, 18 deletions
diff --git a/google_apis/gaia/gaia_auth_fetcher.cc b/google_apis/gaia/gaia_auth_fetcher.cc index 822fc98..4094768 100644 --- a/google_apis/gaia/gaia_auth_fetcher.cc +++ b/google_apis/gaia/gaia_auth_fetcher.cc @@ -675,6 +675,22 @@ void GaiaAuthFetcher::StartCookieForOAuthLoginTokenExchange( fetcher_->Start(); } +void GaiaAuthFetcher::StartAuthCodeForOAuth2TokenExchange( + const std::string& auth_code) { + DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; + + DVLOG(1) << "Starting OAuth token pair fetch"; + request_body_ = MakeGetTokenPairBody(auth_code); + fetcher_.reset(CreateGaiaFetcher(getter_, + request_body_, + "", + oauth2_token_gurl_, + kLoadFlagsIgnoreCookies, + this)); + fetch_pending_ = true; + fetcher_->Start(); +} + void GaiaAuthFetcher::StartGetUserInfo(const std::string& lsid) { DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; @@ -942,27 +958,12 @@ void GaiaAuthFetcher::OnClientLoginToOAuth2Fetched( if (status.is_success() && response_code == net::HTTP_OK) { std::string auth_code; ParseClientLoginToOAuth2Response(cookies, &auth_code); - StartOAuth2TokenPairFetch(auth_code); + StartAuthCodeForOAuth2TokenExchange(auth_code); } else { consumer_->OnClientOAuthFailure(GenerateAuthError(data, status)); } } -void GaiaAuthFetcher::StartOAuth2TokenPairFetch(const std::string& auth_code) { - DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; - - DVLOG(1) << "Starting OAuth token pair fetch"; - request_body_ = MakeGetTokenPairBody(auth_code); - fetcher_.reset(CreateGaiaFetcher(getter_, - request_body_, - "", - oauth2_token_gurl_, - kLoadFlagsIgnoreCookies, - this)); - fetch_pending_ = true; - fetcher_->Start(); -} - void GaiaAuthFetcher::OnOAuth2TokenPairFetched( const std::string& data, const net::URLRequestStatus& status, diff --git a/google_apis/gaia/gaia_auth_fetcher.h b/google_apis/gaia/gaia_auth_fetcher.h index 942bb7b..06ff329 100644 --- a/google_apis/gaia/gaia_auth_fetcher.h +++ b/google_apis/gaia/gaia_auth_fetcher.h @@ -109,6 +109,13 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate { // called on the consumer on the original thread. void StartCookieForOAuthLoginTokenExchange(const std::string& session_index); + // Start a request to exchange the authorization code for an OAuthLogin-scoped + // oauth2 token. + // + // Either OnClientOAuthSuccess or OnClientOAuthFailure will be + // called on the consumer on the original thread. + void StartAuthCodeForOAuth2TokenExchange(const std::string& auth_code); + // Start a request to get user info for the account identified by |lsid|. // // Either OnGetUserInfoSuccess or OnGetUserInfoFailure will be @@ -357,8 +364,6 @@ class GaiaAuthFetcher : public net::URLFetcherDelegate { static std::string MakeOAuthLoginBody(const std::string& service, const std::string& source); - void StartOAuth2TokenPairFetch(const std::string& auth_code); - // Create a fetcher usable for making any Gaia request. |body| is used // as the body of the POST request sent to GAIA. Any strings listed in // |headers| are added as extra HTTP headers in the request. |