Skip to content

Commit

Permalink
Let GaiaOAuthClient::GetTokensFromAuthCode use any given redirect URL.
Browse files Browse the repository at this point in the history
BUG=153453


Review URL: https://chromiumcodereview.appspot.com/11038011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159736 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
simonmorris@chromium.org committed Oct 2, 2012
1 parent 8e9f51b commit 47b7c9a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions chrome/service/cloud_print/cloud_print_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ bool CloudPrintProxy::CreateBackend() {
google_apis::GetOAuth2ClientID(google_apis::CLIENT_CLOUD_PRINT);
oauth_client_info.client_secret =
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_CLOUD_PRINT);
oauth_client_info.redirect_uri = "oob";
backend_.reset(new CloudPrintProxyBackend(this, settings_, oauth_client_info,
enable_job_poll));
return true;
Expand Down
4 changes: 3 additions & 1 deletion google_apis/gaia/gaia_oauth_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ void GaiaOAuthClient::Core::GetTokensFromAuthCode(
true) +
"&client_secret=" +
net::EscapeUrlEncodedData(oauth_client_info.client_secret, true) +
"&redirect_uri=oob&grant_type=authorization_code";
"&redirect_uri=" +
net::EscapeUrlEncodedData(oauth_client_info.redirect_uri, true) +
"&grant_type=authorization_code";
MakeGaiaRequest(post_body, max_retries, delegate);
}

Expand Down
1 change: 1 addition & 0 deletions google_apis/gaia/gaia_oauth_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ static const char kGaiaOAuth2Url[] =
struct OAuthClientInfo {
std::string client_id;
std::string client_secret;
std::string redirect_uri;
};

class GaiaOAuthClient {
Expand Down
5 changes: 5 additions & 0 deletions google_apis/gaia/gaia_oauth_client_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ TEST_F(GaiaOAuthClientTest, NetworkFailure) {
OAuthClientInfo client_info;
client_info.client_id = "test_client_id";
client_info.client_secret = "test_client_secret";
client_info.redirect_uri = "test_redirect_uri";
GaiaOAuthClient auth(kGaiaOAuth2Url,
profile_.GetRequestContext());
auth.GetTokensFromAuthCode(client_info, "auth_code", 2, &delegate);
Expand All @@ -178,6 +179,7 @@ TEST_F(GaiaOAuthClientTest, NetworkFailureRecover) {
OAuthClientInfo client_info;
client_info.client_id = "test_client_id";
client_info.client_secret = "test_client_secret";
client_info.redirect_uri = "test_redirect_uri";
GaiaOAuthClient auth(kGaiaOAuth2Url,
profile_.GetRequestContext());
auth.GetTokensFromAuthCode(client_info, "auth_code", -1, &delegate);
Expand All @@ -199,6 +201,7 @@ TEST_F(GaiaOAuthClientTest, OAuthFailure) {
OAuthClientInfo client_info;
client_info.client_id = "test_client_id";
client_info.client_secret = "test_client_secret";
client_info.redirect_uri = "test_redirect_uri";
GaiaOAuthClient auth(kGaiaOAuth2Url,
profile_.GetRequestContext());
auth.GetTokensFromAuthCode(client_info, "auth_code", -1, &delegate);
Expand All @@ -218,6 +221,7 @@ TEST_F(GaiaOAuthClientTest, GetTokensSuccess) {
OAuthClientInfo client_info;
client_info.client_id = "test_client_id";
client_info.client_secret = "test_client_secret";
client_info.redirect_uri = "test_redirect_uri";
GaiaOAuthClient auth(kGaiaOAuth2Url,
profile_.GetRequestContext());
auth.GetTokensFromAuthCode(client_info, "auth_code", -1, &delegate);
Expand All @@ -236,6 +240,7 @@ TEST_F(GaiaOAuthClientTest, RefreshTokenSuccess) {
OAuthClientInfo client_info;
client_info.client_id = "test_client_id";
client_info.client_secret = "test_client_secret";
client_info.redirect_uri = "test_redirect_uri";
GaiaOAuthClient auth(kGaiaOAuth2Url,
profile_.GetRequestContext());
auth.GetTokensFromAuthCode(client_info, "auth_code", -1, &delegate);
Expand Down

0 comments on commit 47b7c9a

Please sign in to comment.