[email protected] | 6f5f9096 | 2013-08-16 21:28:48 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
nicholss | f620a47c | 2017-02-02 23:39:08 | [diff] [blame] | 5 | #ifndef REMOTING_BASE_OAUTH_CLIENT_H_ |
| 6 | #define REMOTING_BASE_OAUTH_CLIENT_H_ |
[email protected] | 6f5f9096 | 2013-08-16 21:28:48 | [diff] [blame] | 7 | |
[email protected] | 6f5f9096 | 2013-08-16 21:28:48 | [diff] [blame] | 8 | #include <string> |
| 9 | |
| 10 | #include "base/callback.h" |
[email protected] | 305ed87 | 2014-07-08 02:33:53 | [diff] [blame] | 11 | |
jrw | 8544c70 | 2015-04-27 21:45:26 | [diff] [blame] | 12 | namespace gaia { |
| 13 | struct OAuthClientInfo; |
[email protected] | 305ed87 | 2014-07-08 02:33:53 | [diff] [blame] | 14 | } |
[email protected] | 6f5f9096 | 2013-08-16 21:28:48 | [diff] [blame] | 15 | |
| 16 | namespace remoting { |
| 17 | |
jrw | 8544c70 | 2015-04-27 21:45:26 | [diff] [blame] | 18 | class OAuthClient { |
[email protected] | 6f5f9096 | 2013-08-16 21:28:48 | [diff] [blame] | 19 | public: |
| 20 | // Called when GetCredentialsFromAuthCode is completed, with the |user_email| |
| 21 | // and |refresh_token| that correspond to the given |auth_code|, or with empty |
| 22 | // strings on error. |
nicholss | f620a47c | 2017-02-02 23:39:08 | [diff] [blame] | 23 | typedef base::Callback<void(const std::string& user_email, |
| 24 | const std::string& refresh_token)> |
| 25 | CompletionCallback; |
[email protected] | 6f5f9096 | 2013-08-16 21:28:48 | [diff] [blame] | 26 | |
jrw | 8544c70 | 2015-04-27 21:45:26 | [diff] [blame] | 27 | virtual ~OAuthClient() {} |
[email protected] | 6f5f9096 | 2013-08-16 21:28:48 | [diff] [blame] | 28 | |
jrw | ec9abae | 2015-04-24 21:57:08 | [diff] [blame] | 29 | // Redeems |auth_code| using |oauth_client_info| to obtain |
| 30 | // |refresh_token| and |access_token|, then, if |need_user_email| is |
| 31 | // true, uses the userinfo endpoint to obtain |user_email|. Calls |
| 32 | // CompletionCallback with |user_email| and |refresh_token| when |
| 33 | // done, or with empty strings on error. If a request is received |
| 34 | // while another one is being processed, it is enqueued and |
| 35 | // processed after the first one is finished. |
jrw | 8544c70 | 2015-04-27 21:45:26 | [diff] [blame] | 36 | virtual void GetCredentialsFromAuthCode( |
[email protected] | 6f5f9096 | 2013-08-16 21:28:48 | [diff] [blame] | 37 | const gaia::OAuthClientInfo& oauth_client_info, |
| 38 | const std::string& auth_code, |
jrw | ec9abae | 2015-04-24 21:57:08 | [diff] [blame] | 39 | bool need_user_email, |
jrw | 8544c70 | 2015-04-27 21:45:26 | [diff] [blame] | 40 | CompletionCallback on_done) = 0; |
[email protected] | 6f5f9096 | 2013-08-16 21:28:48 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | } // namespace remoting |
| 44 | |
nicholss | f620a47c | 2017-02-02 23:39:08 | [diff] [blame] | 45 | #endif // REMOTING_BASE_OAUTH_CLIENT_H_ |