Defines the interface for access token generators.
Instances of this class can generate OAuth2 access tokens. These are used to authenticate with Google Cloud Platform (and other Google Services), and may be useful for applications that directly invoke REST-based services.
Performance
Creating a new access token is relatively expensive. It may require remote calls via HTTP, or at the very least some (local) cryptographic operations.
Most implementations of this class will cache an access token until it is about to expire. Application developers are advised to keep AccessTokenGenerator instances for as long as possible. They should also avoid caching the access token themselves, as caching is already provided by the implementation.
Thread Safety
It is safe to call an instance of this class from two separate threads.
Error Handling
This class uses StatusOr<T> to report errors. When an operation fails to perform its work the returned StatusOr<T> contains the error details. If the ok() member function in the StatusOr<T> returns true then it contains the expected result. Please consult the google::cloud::StatusOr documentation for more details.
Functions
GetToken()
Returns an OAuth2 access token.
This function caches the access token to avoid the cost of recomputing the token on each call.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-21 UTC."],[[["The latest version of the `AccessTokenGenerator` is 2.37.0-rc, and there are multiple previous versions available for reference, ranging from 2.36.0 down to 2.16.0."],["`AccessTokenGenerator` defines the interface for generating OAuth2 access tokens, which are essential for authenticating with Google Cloud Platform and other Google Services, especially for applications interacting directly with REST-based services."],["Generating new access tokens can be resource-intensive, involving either remote HTTP calls or local cryptographic operations, therefore, implementations of this class cache tokens until they are about to expire."],["The `AccessTokenGenerator` class is thread-safe, allowing it to be safely used by multiple threads concurrently, and it utilizes `StatusOr\u003cT\u003e` to handle errors, providing error details when operations fail."],["The `GetToken()` function is used to obtain an OAuth2 access token, and it caches the token to avoid redundant computations."]]],[]]