#ifndef GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_CONSUMER_H_
#define GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_CONSUMER_H_
#include <string>
#include "base/component_export.h"
#include "base/time/time.h"
class GoogleServiceAuthError;
class COMPONENT_EXPORT(GOOGLE_APIS) OAuth2AccessTokenConsumer {
public:
struct COMPONENT_EXPORT(GOOGLE_APIS) TokenResponse {
TokenResponse();
TokenResponse(const TokenResponse& response);
TokenResponse(TokenResponse&& response);
~TokenResponse();
TokenResponse& operator=(const TokenResponse& response);
TokenResponse& operator=(TokenResponse&& response);
std::string access_token;
std::string refresh_token;
base::Time expiration_time;
std::string id_token;
class COMPONENT_EXPORT(GOOGLE_APIS) Builder {
public:
Builder();
~Builder();
Builder& WithAccessToken(const std::string& token);
Builder& WithRefreshToken(const std::string& token);
Builder& WithExpirationTime(const base::Time& time);
Builder& WithIdToken(const std::string& token);
TokenResponse build();
private:
std::string access_token_;
std::string refresh_token_;
base::Time expiration_time_;
std::string id_token_;
};
private:
friend class Builder;
friend class OAuth2AccessTokenConsumer;
TokenResponse(const std::string& access_token,
const std::string& refresh_token,
const base::Time& expiration_time,
const std::string& id_token);
};
OAuth2AccessTokenConsumer() = default;
OAuth2AccessTokenConsumer(const OAuth2AccessTokenConsumer&) = delete;
OAuth2AccessTokenConsumer& operator=(const OAuth2AccessTokenConsumer&) =
delete;
virtual ~OAuth2AccessTokenConsumer();
virtual void OnGetTokenSuccess(const TokenResponse& token_response);
virtual void OnGetTokenFailure(const GoogleServiceAuthError& error);
virtual std::string GetConsumerName() const = 0;
};
#endif