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
3 // found in the LICENSE file.
5 #ifndef GOOGLE_APIS_DRIVE_AUTH_SERVICE_INTERFACE_H_
6 #define GOOGLE_APIS_DRIVE_AUTH_SERVICE_INTERFACE_H_
10 #include "base/callback_forward.h"
11 #include "google_apis/drive/drive_api_error_codes.h"
13 namespace google_apis
{
15 class AuthServiceObserver
;
17 // Called when fetching of access token is complete.
18 typedef base::Callback
<void(DriveApiErrorCode error
,
19 const std::string
& access_token
)>
22 // This defines an interface for the authentication service which is required
23 // by authenticated requests (AuthenticatedRequestInterface).
24 // All functions must be called on UI thread.
25 class AuthServiceInterface
{
27 virtual ~AuthServiceInterface() {}
29 // Adds and removes the observer.
30 virtual void AddObserver(AuthServiceObserver
* observer
) = 0;
31 virtual void RemoveObserver(AuthServiceObserver
* observer
) = 0;
33 // Starts fetching OAuth2 access token from the refresh token.
34 // |callback| must not be null.
35 virtual void StartAuthentication(const AuthStatusCallback
& callback
) = 0;
37 // True if an OAuth2 access token is retrieved and believed to be fresh.
38 // The access token is used to access the Drive server.
39 virtual bool HasAccessToken() const = 0;
41 // True if an OAuth2 refresh token is present. Its absence means that user
42 // is not properly authenticated.
43 // The refresh token is used to get the access token.
44 virtual bool HasRefreshToken() const = 0;
46 // Returns OAuth2 access token.
47 virtual const std::string
& access_token() const = 0;
49 // Clears OAuth2 access token.
50 virtual void ClearAccessToken() = 0;
52 // Clears OAuth2 refresh token.
53 virtual void ClearRefreshToken() = 0;
56 } // namespace google_apis
58 #endif // GOOGLE_APIS_DRIVE_AUTH_SERVICE_INTERFACE_H_