Google Cloud Storage C++ Client  1.42.0
A C++ Client Library for Google Cloud Storage
Public Member Functions | List of all members
google::cloud::storage::oauth2::Credentials Class Referenceabstract

Interface for OAuth 2.0 credentials used to access Google Cloud services. More...

#include <google/cloud/storage/oauth2/credentials.h>

Public Member Functions

virtual ~Credentials ()=default
 
virtual StatusOr< std::string > AuthorizationHeader ()=0
 Attempts to obtain a value for the Authorization HTTP header. More...
 
virtual StatusOr< std::vector< std::uint8_t > > SignBlob (SigningAccount const &service_account, std::string const &string_to_sign) const
 Try to sign string_to_sign using service_account. More...
 
virtual std::string AccountEmail () const
 Return the account's email associated with these credentials, if any. More...
 
virtual std::string KeyId () const
 Return the account's key_id associated with these credentials, if any. More...
 

Detailed Description

Interface for OAuth 2.0 credentials used to access Google Cloud services.

Instantiating a specific kind of Credentials should usually be done via the convenience methods declared in google_credentials.h.

See also
https://cloud.google.com/docs/authentication/ for an overview of authenticating to Google Cloud Platform APIs.

Definition at line 39 of file credentials.h.

Constructor & Destructor Documentation

◆ ~Credentials()

virtual google::cloud::storage::oauth2::Credentials::~Credentials ( )
virtualdefault

Member Function Documentation

◆ AccountEmail()

virtual std::string google::cloud::storage::oauth2::Credentials::AccountEmail ( ) const
inlinevirtual

◆ AuthorizationHeader()

virtual StatusOr<std::string> google::cloud::storage::oauth2::Credentials::AuthorizationHeader ( )
pure virtual

Attempts to obtain a value for the Authorization HTTP header.

If unable to obtain a value for the Authorization header, which could happen for Credentials that need to be periodically refreshed, the underlying Status will indicate failure details from the refresh HTTP request. Otherwise, the returned value will contain the Authorization header to be used in HTTP requests.

Implemented in google::cloud::storage::oauth2::ServiceAccountCredentials< HttpRequestBuilderType, ClockType >, google::cloud::storage::oauth2::ComputeEngineCredentials< HttpRequestBuilderType, ClockType >, google::cloud::storage::oauth2::AuthorizedUserCredentials< HttpRequestBuilderType, ClockType >, and google::cloud::storage::oauth2::AnonymousCredentials.

◆ KeyId()

virtual std::string google::cloud::storage::oauth2::Credentials::KeyId ( ) const
inlinevirtual

Return the account's key_id associated with these credentials, if any.

Reimplemented in google::cloud::storage::oauth2::ServiceAccountCredentials< HttpRequestBuilderType, ClockType >.

Definition at line 70 of file credentials.h.

◆ SignBlob()

virtual StatusOr<std::vector<std::uint8_t> > google::cloud::storage::oauth2::Credentials::SignBlob ( SigningAccount const &  service_account,
std::string const &  string_to_sign 
) const
virtual

Try to sign string_to_sign using service_account.

Some Credentials types can locally sign a blob, most often just on behalf of an specific service account. This function returns an error if the credentials cannot sign the blob at all, or if the service account is a mismatch.

Reimplemented in google::cloud::storage::oauth2::ServiceAccountCredentials< HttpRequestBuilderType, ClockType >.