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_GAIA_GAIA_AUTH_CONSUMER_H_
6 #define GOOGLE_APIS_GAIA_GAIA_AUTH_CONSUMER_H_
12 class GoogleServiceAuthError
;
15 typedef std::vector
<std::string
> ResponseCookies
;
18 typedef std::map
<std::string
, std::string
> UserInfoMap
;
20 // An interface that defines the callbacks for objects that
21 // GaiaAuthFetcher can return data to.
22 class GaiaAuthConsumer
{
24 struct ClientLoginResult
{
26 ClientLoginResult(const std::string
& new_sid
,
27 const std::string
& new_lsid
,
28 const std::string
& new_token
,
29 const std::string
& new_data
);
32 bool operator==(const ClientLoginResult
&b
) const;
37 // TODO(chron): Remove the data field later. Don't use it if possible.
38 std::string data
; // Full contents of ClientLogin return.
39 bool two_factor
; // set to true if there was a TWO_FACTOR "failure".
42 struct ClientOAuthResult
{
44 ClientOAuthResult(const std::string
& new_refresh_token
,
45 const std::string
& new_access_token
,
46 int new_expires_in_secs
);
49 bool operator==(const ClientOAuthResult
&b
) const;
51 // OAuth2 refresh token. Used to mint new access tokens when needed.
52 std::string refresh_token
;
54 // OAuth2 access token. Token to pass to endpoints that require oauth2
56 std::string access_token
;
58 // The lifespan of |access_token| in seconds.
62 virtual ~GaiaAuthConsumer() {}
64 virtual void OnClientLoginSuccess(const ClientLoginResult
& result
) {}
65 virtual void OnClientLoginFailure(const GoogleServiceAuthError
& error
) {}
67 virtual void OnIssueAuthTokenSuccess(const std::string
& service
,
68 const std::string
& auth_token
) {}
69 virtual void OnIssueAuthTokenFailure(const std::string
& service
,
70 const GoogleServiceAuthError
& error
) {}
72 virtual void OnClientOAuthSuccess(const ClientOAuthResult
& result
) {}
73 virtual void OnClientOAuthFailure(const GoogleServiceAuthError
& error
) {}
75 virtual void OnOAuth2RevokeTokenCompleted() {}
77 virtual void OnGetUserInfoSuccess(const UserInfoMap
& data
) {}
78 virtual void OnGetUserInfoFailure(const GoogleServiceAuthError
& error
) {}
80 virtual void OnUberAuthTokenSuccess(const std::string
& token
) {}
81 virtual void OnUberAuthTokenFailure(const GoogleServiceAuthError
& error
) {}
83 virtual void OnMergeSessionSuccess(const std::string
& data
) {}
84 virtual void OnMergeSessionFailure(const GoogleServiceAuthError
& error
) {}
86 virtual void OnListAccountsSuccess(const std::string
& data
) {}
87 virtual void OnListAccountsFailure(const GoogleServiceAuthError
& error
) {}
90 #endif // GOOGLE_APIS_GAIA_GAIA_AUTH_CONSUMER_H_