| 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 #ifndef GOOGLE_APIS_GAIA_GAIA_OAUTH_CLIENT_H_ | 5 #ifndef GOOGLE_APIS_GAIA_GAIA_OAUTH_CLIENT_H_ |
| 6 #define GOOGLE_APIS_GAIA_GAIA_OAUTH_CLIENT_H_ | 6 #define GOOGLE_APIS_GAIA_GAIA_OAUTH_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 virtual void OnGetTokensResponse(const std::string& refresh_token, | 40 virtual void OnGetTokensResponse(const std::string& refresh_token, |
| 41 const std::string& access_token, | 41 const std::string& access_token, |
| 42 int expires_in_seconds) {} | 42 int expires_in_seconds) {} |
| 43 // Invoked on a successful response to the RefreshToken request. | 43 // Invoked on a successful response to the RefreshToken request. |
| 44 virtual void OnRefreshTokenResponse(const std::string& access_token, | 44 virtual void OnRefreshTokenResponse(const std::string& access_token, |
| 45 int expires_in_seconds) {} | 45 int expires_in_seconds) {} |
| 46 // Invoked on a successful response to the GetUserInfo request. | 46 // Invoked on a successful response to the GetUserInfo request. |
| 47 virtual void OnGetUserEmailResponse(const std::string& user_email) {} | 47 virtual void OnGetUserEmailResponse(const std::string& user_email) {} |
| 48 // Invoked on a successful response to the GetUserId request. | 48 // Invoked on a successful response to the GetUserId request. |
| 49 virtual void OnGetUserIdResponse(const std::string& user_id) {} | 49 virtual void OnGetUserIdResponse(const std::string& user_id) {} |
| 50 // Invoked on a successful response to the GetUserInfo request. | |
| 51 virtual void OnGetUserInfoResponse( | |
| 52 scoped_ptr<base::DictionaryValue> user_info) {} | |
| 53 // Invoked on a successful response to the GetTokenInfo request. | 50 // Invoked on a successful response to the GetTokenInfo request. |
| 54 virtual void OnGetTokenInfoResponse( | 51 virtual void OnGetTokenInfoResponse( |
| 55 scoped_ptr<base::DictionaryValue> token_info) {} | 52 scoped_ptr<base::DictionaryValue> token_info) {} |
| 56 // Invoked when there is an OAuth error with one of the requests. | 53 // Invoked when there is an OAuth error with one of the requests. |
| 57 virtual void OnOAuthError() = 0; | 54 virtual void OnOAuthError() = 0; |
| 58 // Invoked when there is a network error or upon receiving an invalid | 55 // Invoked when there is a network error or upon receiving an invalid |
| 59 // response. This is invoked when the maximum number of retries have been | 56 // response. This is invoked when the maximum number of retries have been |
| 60 // exhausted. If max_retries is -1, this is never invoked. | 57 // exhausted. If max_retries is -1, this is never invoked. |
| 61 virtual void OnNetworkError(int response_code) = 0; | 58 virtual void OnNetworkError(int response_code) = 0; |
| 62 | 59 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 84 // |GetTokensFromAuthCode()|), fetch a fresh access token that can be used | 81 // |GetTokensFromAuthCode()|), fetch a fresh access token that can be used |
| 85 // to authenticate an API call. If |scopes| is non-empty, then fetch an | 82 // to authenticate an API call. If |scopes| is non-empty, then fetch an |
| 86 // access token for those specific scopes (assuming the refresh token has the | 83 // access token for those specific scopes (assuming the refresh token has the |
| 87 // appropriate permissions). See |max_retries| docs above. | 84 // appropriate permissions). See |max_retries| docs above. |
| 88 void RefreshToken(const OAuthClientInfo& oauth_client_info, | 85 void RefreshToken(const OAuthClientInfo& oauth_client_info, |
| 89 const std::string& refresh_token, | 86 const std::string& refresh_token, |
| 90 const std::vector<std::string>& scopes, | 87 const std::vector<std::string>& scopes, |
| 91 int max_retries, | 88 int max_retries, |
| 92 Delegate* delegate); | 89 Delegate* delegate); |
| 93 | 90 |
| 94 // Call the people.get API, returning the user email address associated | 91 // Call the userinfo API, returning the user email address associated |
| 95 // with the given access token. The provided access token must have | 92 // with the given access token. The provided access token must have |
| 96 // https://www.googleapis.com/auth/userinfo.email as one of its scopes. | 93 // https://www.googleapis.com/auth/userinfo.email as one of its scopes. |
| 97 // See |max_retries| docs above. | 94 // See |max_retries| docs above. |
| 98 void GetUserEmail(const std::string& oauth_access_token, | 95 void GetUserEmail(const std::string& oauth_access_token, |
| 99 int max_retries, | 96 int max_retries, |
| 100 Delegate* delegate); | 97 Delegate* delegate); |
| 101 | 98 |
| 102 // Call the people.get API, returning the user gaia ID associated | 99 // Call the userinfo API, returning the user gaia ID associated |
| 103 // with the given access token. The provided access token must have | 100 // with the given access token. The provided access token must have |
| 104 // https://www.googleapis.com/auth/userinfo.profile as one of its scopes. | 101 // https://www.googleapis.com/auth/userinfo as one of its scopes. |
| 105 // See |max_retries| docs above. | 102 // See |max_retries| docs above. |
| 106 void GetUserId(const std::string& oauth_access_token, | 103 void GetUserId(const std::string& oauth_access_token, |
| 107 int max_retries, | 104 int max_retries, |
| 108 Delegate* delegate); | 105 Delegate* delegate); |
| 109 | 106 |
| 110 // Call the people.get API, returning the user info associated | |
| 111 // with the given access token. The provided access token must have | |
| 112 // https://www.googleapis.com/auth/userinfo.email and | |
| 113 // https://www.googleapis.com/auth/userinfo.profile as its scopes. | |
| 114 // See |max_retries| docs above. | |
| 115 void GetUserInfo(const std::string& oauth_access_token, | |
| 116 int max_retries, | |
| 117 Delegate* delegate); | |
| 118 | |
| 119 // Call the tokeninfo API, returning a dictionary of response values. The | 107 // Call the tokeninfo API, returning a dictionary of response values. The |
| 120 // provided access token may have any scope, and basic results will be | 108 // provided access token may have any scope, and basic results will be |
| 121 // returned: issued_to, audience, scope, expires_in, access_type. In | 109 // returned: issued_to, audience, scope, expires_in, access_type. In |
| 122 // addition, if the https://www.googleapis.com/auth/userinfo.email scope is | 110 // addition, if the https://www.googleapis.com/auth/userinfo.email scope is |
| 123 // present, the email and verified_email fields will be returned. If the | 111 // present, the email and verified_email fields will be returned. If the |
| 124 // https://www.googleapis.com/auth/userinfo.profile scope is present, the | 112 // https://www.googleapis.com/auth/userinfo.profile scope is present, the |
| 125 // user_id field will be returned. See |max_retries| docs above. | 113 // user_id field will be returned. See |max_retries| docs above. |
| 126 void GetTokenInfo(const std::string& oauth_access_token, | 114 void GetTokenInfo(const std::string& oauth_access_token, |
| 127 int max_retries, | 115 int max_retries, |
| 128 Delegate* delegate); | 116 Delegate* delegate); |
| 129 | 117 |
| 130 private: | 118 private: |
| 131 // The guts of the implementation live in this class. | 119 // The guts of the implementation live in this class. |
| 132 class Core; | 120 class Core; |
| 133 scoped_refptr<Core> core_; | 121 scoped_refptr<Core> core_; |
| 134 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthClient); | 122 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthClient); |
| 135 }; | 123 }; |
| 136 } | 124 } |
| 137 | 125 |
| 138 #endif // GOOGLE_APIS_GAIA_GAIA_OAUTH_CLIENT_H_ | 126 #endif // GOOGLE_APIS_GAIA_GAIA_OAUTH_CLIENT_H_ |
| OLD | NEW |