Reference documentation and code samples for the googleauth class Google::Auth::BearerTokenCredentials.
Implementation of Bearer Token authentication scenario.
Bearer tokens are strings representing an authorization grant.
They can be OAuth2 ("ya.29") tokens, JWTs, IDTokens -- anything
that is sent as a Bearer
in an Authorization
header.
Not all 'authentication' strings can be used with this class,
e.g. an API key cannot since API keys are sent in a
x-goog-api-key
header or as a query parameter.
This class should be used when the end-user is managing the authentication token separately, e.g. with a separate service. This means that tasks like tracking the lifetime of and refreshing the token are outside the scope of this class.
There is no JSON representation for this type of credentials. If the end-user has credentials in JSON format they should typically use the corresponding credentials type, e.g. ServiceAccountCredentials with the service account JSON.
Inherits
- Object
Includes
Methods
.make_creds
def self.make_creds(options = {}) -> Google::Auth::BearerTokenCredentials
Create the BearerTokenCredentials.
- options (Hash) — The credentials options
#bearer_token
def bearer_token() -> String
The following aliasing is needed for BaseClient since it sends :token_type
- (String) — The token to be sent as a part of Bearer claim
#duplicate
def duplicate(options = {}) -> Google::Auth::BearerTokenCredentials
Creates a duplicate of these credentials.
- options (Hash) — Additional options for configuring the credentials
#expires_at
def expires_at() -> Time, nil
- (Time, nil) — The token expiration time provided by the end-user.
#expires_within?
def expires_within?(seconds) -> Boolean
Determines if the credentials object has expired.
- seconds (Numeric) — The optional timeout in seconds.
- (Boolean) — True if the token has expired, false otherwise, or if the expires_at was not provided.
#initialize
def initialize(options = {}) -> BearerTokenCredentials
Initialize the BearerTokenCredentials.
- options (Hash) — The credentials options
- (BearerTokenCredentials) — a new instance of BearerTokenCredentials
- (ArgumentError)
#token
def token() -> String
- (String) — The token to be sent as a part of Bearer claim
#universe_domain
def universe_domain() -> String
- (String) — The universe domain of the universe this token is for
#universe_domain=
def universe_domain=(value) -> String
- value (String) — The universe domain of the universe this token is for
- (String) — The universe domain of the universe this token is for