| OLD | NEW |
| 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_urls.h" | 5 #include "google_apis/gaia/gaia_urls.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "google_apis/gaia/gaia_switches.h" | 8 #include "google_apis/gaia/gaia_switches.h" |
| 9 #include "google_apis/google_api_keys.h" | 9 #include "google_apis/google_api_keys.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 // Gaia service constants | 13 // Gaia service constants |
| 14 const char kDefaultGaiaBaseUrl[] = "accounts.google.com"; | 14 const char kDefaultGaiaBaseUrl[] = "accounts.google.com"; |
| 15 | |
| 16 // Gaia service constants | |
| 17 const char kDefaultGaiaOAuthBaseUrl[] = "www.google.com"; | |
| 18 | |
| 19 const char kCaptchaUrlPrefixSuffix[] = "/"; | 15 const char kCaptchaUrlPrefixSuffix[] = "/"; |
| 20 const char kClientLoginUrlSuffix[] = "/ClientLogin"; | 16 const char kClientLoginUrlSuffix[] = "/ClientLogin"; |
| 21 const char kServiceLoginUrlSuffix[] = "/ServiceLogin"; | 17 const char kServiceLoginUrlSuffix[] = "/ServiceLogin"; |
| 22 const char kIssueAuthTokenUrlSuffix[] = "/IssueAuthToken"; | 18 const char kIssueAuthTokenUrlSuffix[] = "/IssueAuthToken"; |
| 23 const char kGetUserInfoUrlSuffix[] = "/GetUserInfo"; | 19 const char kGetUserInfoUrlSuffix[] = "/GetUserInfo"; |
| 24 const char kTokenAuthUrlSuffix[] = "/TokenAuth"; | 20 const char kTokenAuthUrlSuffix[] = "/TokenAuth"; |
| 25 const char kMergeSessionUrlSuffix[] = "/MergeSession"; | 21 const char kMergeSessionUrlSuffix[] = "/MergeSession"; |
| 26 | 22 |
| 27 const char kOAuthGetAccessTokenUrlSuffix[] = "/OAuthGetAccessToken"; | 23 const char kOAuthGetAccessTokenUrlSuffix[] = "/OAuthGetAccessToken"; |
| 28 const char kOAuthWrapBridgeUrlSuffix[] = "/OAuthWrapBridge"; | 24 const char kOAuthWrapBridgeUrlSuffix[] = "/OAuthWrapBridge"; |
| 29 const char kOAuth1LoginUrlSuffix[] = "/OAuthLogin"; | 25 const char kOAuth1LoginUrlSuffix[] = "/OAuthLogin"; |
| 30 const char kOAuthRevokeTokenUrlSuffix[] = "/AuthSubRevokeToken"; | 26 const char kOAuthRevokeTokenUrlSuffix[] = "/AuthSubRevokeToken"; |
| 31 | 27 |
| 32 // Federated login constants | 28 // Federated login constants |
| 33 const char kDefaultFederatedLoginHost[] = "www.google.com"; | 29 const char kDefaultFederatedLoginHost[] = "www.google.com"; |
| 34 const char kDefaultFederatedLoginPath[] = "/accounts"; | 30 const char kDefaultFederatedLoginPath[] = "/accounts"; |
| 35 const char kGetOAuthTokenUrlSuffix[] = "/o8/GetOAuthToken"; | 31 const char kGetOAuthTokenUrlSuffix[] = "/o/oauth/GetOAuthToken/"; |
| 36 | 32 |
| 37 const char kClientLoginToOAuth2Url[] = | 33 const char kClientLoginToOAuth2Url[] = |
| 38 "https://accounts.google.com/o/oauth2/programmatic_auth"; | 34 "https://accounts.google.com/o/oauth2/programmatic_auth"; |
| 39 const char kOAuth2TokenUrl[] = | 35 const char kOAuth2TokenUrl[] = |
| 40 "https://accounts.google.com/o/oauth2/token"; | 36 "https://accounts.google.com/o/oauth2/token"; |
| 41 const char kOAuth2IssueTokenUrl[] = | 37 const char kOAuth2IssueTokenUrl[] = |
| 42 "https://www.googleapis.com/oauth2/v2/IssueToken"; | 38 "https://www.googleapis.com/oauth2/v2/IssueToken"; |
| 43 const char kOAuth1LoginScope[] = | 39 const char kOAuth1LoginScope[] = |
| 44 "https://www.google.com/accounts/OAuthLogin"; | 40 "https://www.google.com/accounts/OAuthLogin"; |
| 45 | 41 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 gaia_url_base.append(path); | 75 gaia_url_base.append(path); |
| 80 } | 76 } |
| 81 } | 77 } |
| 82 | 78 |
| 83 client_login_url_ = gaia_url_base + kClientLoginUrlSuffix; | 79 client_login_url_ = gaia_url_base + kClientLoginUrlSuffix; |
| 84 service_login_url_ = gaia_url_base + kServiceLoginUrlSuffix; | 80 service_login_url_ = gaia_url_base + kServiceLoginUrlSuffix; |
| 85 issue_auth_token_url_ = gaia_url_base + kIssueAuthTokenUrlSuffix; | 81 issue_auth_token_url_ = gaia_url_base + kIssueAuthTokenUrlSuffix; |
| 86 get_user_info_url_ = gaia_url_base + kGetUserInfoUrlSuffix; | 82 get_user_info_url_ = gaia_url_base + kGetUserInfoUrlSuffix; |
| 87 token_auth_url_ = gaia_url_base + kTokenAuthUrlSuffix; | 83 token_auth_url_ = gaia_url_base + kTokenAuthUrlSuffix; |
| 88 merge_session_url_ = gaia_url_base + kMergeSessionUrlSuffix; | 84 merge_session_url_ = gaia_url_base + kMergeSessionUrlSuffix; |
| 89 | 85 get_oauth_token_url_ = gaia_url_base + kGetOAuthTokenUrlSuffix; |
| 90 // Federated login is not part of Gaia and has its own endpoints. | |
| 91 std::string oauth_host_base; | |
| 92 GetSwitchValueWithDefault(switches::kGaiaOAuthHost, | |
| 93 kDefaultFederatedLoginHost, | |
| 94 &oauth_host_base); | |
| 95 | |
| 96 std::string gaia_oauth_url_base = "https://"+oauth_host_base; | |
| 97 if (command_line->HasSwitch(switches::kGaiaOAuthUrlPath)) { | |
| 98 std::string path = | |
| 99 command_line->GetSwitchValueASCII(switches::kGaiaOAuthUrlPath); | |
| 100 if (!path.empty()) { | |
| 101 if (path[0] != '/') | |
| 102 gaia_oauth_url_base.append("/"); | |
| 103 | |
| 104 gaia_oauth_url_base.append(path); | |
| 105 } | |
| 106 } else { | |
| 107 gaia_oauth_url_base.append(kDefaultFederatedLoginPath); | |
| 108 } | |
| 109 get_oauth_token_url_ = gaia_oauth_url_base + | |
| 110 kGetOAuthTokenUrlSuffix; | |
| 111 | |
| 112 oauth_get_access_token_url_ = gaia_url_base + | 86 oauth_get_access_token_url_ = gaia_url_base + |
| 113 kOAuthGetAccessTokenUrlSuffix; | 87 kOAuthGetAccessTokenUrlSuffix; |
| 114 oauth_wrap_bridge_url_ = gaia_url_base + kOAuthWrapBridgeUrlSuffix; | 88 oauth_wrap_bridge_url_ = gaia_url_base + kOAuthWrapBridgeUrlSuffix; |
| 115 oauth_revoke_token_url_ = gaia_url_base + kOAuthRevokeTokenUrlSuffix; | 89 oauth_revoke_token_url_ = gaia_url_base + kOAuthRevokeTokenUrlSuffix; |
| 116 oauth1_login_url_ = gaia_url_base + kOAuth1LoginUrlSuffix; | 90 oauth1_login_url_ = gaia_url_base + kOAuth1LoginUrlSuffix; |
| 117 | 91 |
| 118 GetSwitchValueWithDefault(switches::kOAuth1LoginScope, | 92 GetSwitchValueWithDefault(switches::kOAuth1LoginScope, |
| 119 kOAuth1LoginScope, | 93 kOAuth1LoginScope, |
| 120 &oauth1_login_scope_); | 94 &oauth1_login_scope_); |
| 121 | 95 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 207 } |
| 234 | 208 |
| 235 const std::string& GaiaUrls::oauth2_issue_token_url() { | 209 const std::string& GaiaUrls::oauth2_issue_token_url() { |
| 236 return oauth2_issue_token_url_; | 210 return oauth2_issue_token_url_; |
| 237 } | 211 } |
| 238 | 212 |
| 239 | 213 |
| 240 const std::string& GaiaUrls::gaia_login_form_realm() { | 214 const std::string& GaiaUrls::gaia_login_form_realm() { |
| 241 return gaia_login_form_realm_; | 215 return gaia_login_form_realm_; |
| 242 } | 216 } |
| OLD | NEW |