blob: d6cfda3f1470c34bf64415dbb06fdff986773d1d [file] [log] [blame]
[email protected]6f5f90962013-08-16 21:28:481// 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
nicholssf620a47c2017-02-02 23:39:085#ifndef REMOTING_BASE_OAUTH_CLIENT_H_
6#define REMOTING_BASE_OAUTH_CLIENT_H_
[email protected]6f5f90962013-08-16 21:28:487
[email protected]6f5f90962013-08-16 21:28:488#include <string>
9
10#include "base/callback.h"
[email protected]305ed872014-07-08 02:33:5311
jrw8544c702015-04-27 21:45:2612namespace gaia {
13struct OAuthClientInfo;
[email protected]305ed872014-07-08 02:33:5314}
[email protected]6f5f90962013-08-16 21:28:4815
16namespace remoting {
17
jrw8544c702015-04-27 21:45:2618class OAuthClient {
[email protected]6f5f90962013-08-16 21:28:4819 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.
nicholssf620a47c2017-02-02 23:39:0823 typedef base::Callback<void(const std::string& user_email,
24 const std::string& refresh_token)>
25 CompletionCallback;
[email protected]6f5f90962013-08-16 21:28:4826
jrw8544c702015-04-27 21:45:2627 virtual ~OAuthClient() {}
[email protected]6f5f90962013-08-16 21:28:4828
jrwec9abae2015-04-24 21:57:0829 // 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.
jrw8544c702015-04-27 21:45:2636 virtual void GetCredentialsFromAuthCode(
[email protected]6f5f90962013-08-16 21:28:4837 const gaia::OAuthClientInfo& oauth_client_info,
38 const std::string& auth_code,
jrwec9abae2015-04-24 21:57:0839 bool need_user_email,
jrw8544c702015-04-27 21:45:2640 CompletionCallback on_done) = 0;
[email protected]6f5f90962013-08-16 21:28:4841};
42
43} // namespace remoting
44
nicholssf620a47c2017-02-02 23:39:0845#endif // REMOTING_BASE_OAUTH_CLIENT_H_