Class AuthorizedUserCredentials<HttpRequestBuilderType, ClockType> (2.19.0)

Wrapper class for Google OAuth 2.0 user account credentials.

Takes a AuthorizedUserCredentialsInfo and obtains access tokens from the Google Authorization Service as needed. Instances of this class should usually be created via the convenience methods declared in google_credentials.h.

An HTTP Authorization header, with an access token as its value, can be obtained by calling the AuthorizationHeader() method; if the current access token is invalid or nearing expiration, this will class will first obtain a new access token before returning the Authorization header string.

See Also

https://developers.google.com/identity/protocols/OAuth2 for an overview of using user credentials with Google's OAuth 2.0 system.

Prefer using the unified credentials documented in Authentication Components

Constructors

AuthorizedUserCredentials(AuthorizedUserCredentialsInfo, ChannelOptions const &)

Parameters
NameDescription
info AuthorizedUserCredentialsInfo
channel_options ChannelOptions const &

Functions

virtual 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