1 // Copyright 2014 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.
5 #ifndef REMOTING_HOST_OAUTH_TOKEN_GETTER_H_
6 #define REMOTING_HOST_OAUTH_TOKEN_GETTER_H_
10 #include "base/callback.h"
15 // OAuthTokenGetter caches OAuth access tokens and refreshes them as needed.
16 class OAuthTokenGetter
{
18 // Status of the refresh token attempt.
20 // Success, credentials in user_email/access_token.
22 // Network failure (caller may retry).
24 // Authentication failure (permanent).
28 typedef base::Callback
<void(Status status
,
29 const std::string
& user_email
,
30 const std::string
& access_token
)> TokenCallback
;
32 // This structure contains information required to perform
33 // authentication to OAuth2.
34 struct OAuthCredentials
{
35 // |is_service_account| should be True if the OAuth refresh token is for a
36 // service account, False for a user account, to allow the correct client-ID
38 OAuthCredentials(const std::string
& login
,
39 const std::string
& refresh_token
,
40 bool is_service_account
);
42 // The user's account name (i.e. their email address).
45 // Token delegating authority to us to act as the user.
46 std::string refresh_token
;
48 // Whether these credentials belong to a service account.
49 bool is_service_account
;
53 virtual ~OAuthTokenGetter() {}
55 // Call |on_access_token| with an access token, or the failure status.
56 virtual void CallWithToken(
57 const OAuthTokenGetter::TokenCallback
& on_access_token
) = 0;
59 DISALLOW_COPY_AND_ASSIGN(OAuthTokenGetter
);
62 } // namespace remoting
64 #endif // REMOTING_HOST_OAUTH_TOKEN_GETTER_H_