Class Credentials (2.19.0)

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.

Prefer using the unified credentials documented in Authentication Components

Functions

AuthorizationHeader()

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.

Returns
TypeDescription
StatusOr< std::string >

virtual SignBlob(SigningAccount const &, std::string const &) const

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.

Parameters
NameDescription
service_account SigningAccount const &
string_to_sign std::string const &
Returns
TypeDescription
StatusOr< std::vector< std::uint8_t > >

virtual AccountEmail() const

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

Returns
TypeDescription
std::string

virtual KeyId() const

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

Returns
TypeDescription
std::string