Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: google_apis/gaia/gaia_oauth_client.h

Issue 257773002: Use new people.get api instead of oauth2/v1/userinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PD tests Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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) {}
50 // Invoked on a successful response to the GetTokenInfo request. 53 // Invoked on a successful response to the GetTokenInfo request.
51 virtual void OnGetTokenInfoResponse( 54 virtual void OnGetTokenInfoResponse(
52 scoped_ptr<base::DictionaryValue> token_info) {} 55 scoped_ptr<base::DictionaryValue> token_info) {}
53 // Invoked when there is an OAuth error with one of the requests. 56 // Invoked when there is an OAuth error with one of the requests.
54 virtual void OnOAuthError() = 0; 57 virtual void OnOAuthError() = 0;
55 // Invoked when there is a network error or upon receiving an invalid 58 // Invoked when there is a network error or upon receiving an invalid
56 // response. This is invoked when the maximum number of retries have been 59 // response. This is invoked when the maximum number of retries have been
57 // exhausted. If max_retries is -1, this is never invoked. 60 // exhausted. If max_retries is -1, this is never invoked.
58 virtual void OnNetworkError(int response_code) = 0; 61 virtual void OnNetworkError(int response_code) = 0;
59 62
(...skipping 21 matching lines...) Expand all
81 // |GetTokensFromAuthCode()|), fetch a fresh access token that can be used 84 // |GetTokensFromAuthCode()|), fetch a fresh access token that can be used
82 // to authenticate an API call. If |scopes| is non-empty, then fetch an 85 // to authenticate an API call. If |scopes| is non-empty, then fetch an
83 // access token for those specific scopes (assuming the refresh token has the 86 // access token for those specific scopes (assuming the refresh token has the
84 // appropriate permissions). See |max_retries| docs above. 87 // appropriate permissions). See |max_retries| docs above.
85 void RefreshToken(const OAuthClientInfo& oauth_client_info, 88 void RefreshToken(const OAuthClientInfo& oauth_client_info,
86 const std::string& refresh_token, 89 const std::string& refresh_token,
87 const std::vector<std::string>& scopes, 90 const std::vector<std::string>& scopes,
88 int max_retries, 91 int max_retries,
89 Delegate* delegate); 92 Delegate* delegate);
90 93
91 // Call the userinfo API, returning the user email address associated 94 // Call the people.get API, returning the user email address associated
92 // with the given access token. The provided access token must have 95 // with the given access token. The provided access token must have
93 // https://www.googleapis.com/auth/userinfo.email as one of its scopes. 96 // https://www.googleapis.com/auth/userinfo.email as one of its scopes.
94 // See |max_retries| docs above. 97 // See |max_retries| docs above.
95 void GetUserEmail(const std::string& oauth_access_token, 98 void GetUserEmail(const std::string& oauth_access_token,
96 int max_retries, 99 int max_retries,
97 Delegate* delegate); 100 Delegate* delegate);
98 101
99 // Call the userinfo API, returning the user gaia ID associated 102 // Call the people.get API, returning the user gaia ID associated
100 // with the given access token. The provided access token must have 103 // with the given access token. The provided access token must have
101 // https://www.googleapis.com/auth/userinfo as one of its scopes. 104 // https://www.googleapis.com/auth/userinfo.profile as one of its scopes.
102 // See |max_retries| docs above. 105 // See |max_retries| docs above.
103 void GetUserId(const std::string& oauth_access_token, 106 void GetUserId(const std::string& oauth_access_token,
104 int max_retries, 107 int max_retries,
105 Delegate* delegate); 108 Delegate* delegate);
106 109
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,
noms (inactive) 2014/04/25 17:07:40 nit: wrong indentation
Roger Tawa OOO till Jul 10th 2014/04/28 20:44:12 Done.
117 Delegate* delegate);
118
107 // Call the tokeninfo API, returning a dictionary of response values. The 119 // Call the tokeninfo API, returning a dictionary of response values. The
108 // provided access token may have any scope, and basic results will be 120 // provided access token may have any scope, and basic results will be
109 // returned: issued_to, audience, scope, expires_in, access_type. In 121 // returned: issued_to, audience, scope, expires_in, access_type. In
110 // addition, if the https://www.googleapis.com/auth/userinfo.email scope is 122 // addition, if the https://www.googleapis.com/auth/userinfo.email scope is
111 // present, the email and verified_email fields will be returned. If the 123 // present, the email and verified_email fields will be returned. If the
112 // https://www.googleapis.com/auth/userinfo.profile scope is present, the 124 // https://www.googleapis.com/auth/userinfo.profile scope is present, the
113 // user_id field will be returned. See |max_retries| docs above. 125 // user_id field will be returned. See |max_retries| docs above.
114 void GetTokenInfo(const std::string& oauth_access_token, 126 void GetTokenInfo(const std::string& oauth_access_token,
115 int max_retries, 127 int max_retries,
116 Delegate* delegate); 128 Delegate* delegate);
117 129
118 private: 130 private:
119 // The guts of the implementation live in this class. 131 // The guts of the implementation live in this class.
120 class Core; 132 class Core;
121 scoped_refptr<Core> core_; 133 scoped_refptr<Core> core_;
122 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthClient); 134 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthClient);
123 }; 135 };
124 } 136 }
125 137
126 #endif // GOOGLE_APIS_GAIA_GAIA_OAUTH_CLIENT_H_ 138 #endif // GOOGLE_APIS_GAIA_GAIA_OAUTH_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698