googleauth - Class Google::Auth::BearerTokenCredentials (v1.14.0)

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

Methods

.make_creds

def self.make_creds(options = {}) -> Google::Auth::BearerTokenCredentials

Create the BearerTokenCredentials.

Parameter
  • options (Hash) — The credentials options

#bearer_token

def bearer_token() -> String
Alias Of: #token

The following aliasing is needed for BaseClient since it sends :token_type

Returns
  • (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.

Parameter
  • options (Hash) — Additional options for configuring the credentials

#expires_at

def expires_at() -> Time, nil
Returns
  • (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.

Parameter
  • seconds (Numeric) — The optional timeout in seconds.
Returns
  • (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.

Parameter
  • options (Hash) — The credentials options
Returns
Raises
  • (ArgumentError)

#token

def token() -> String
Aliases
Returns
  • (String) — The token to be sent as a part of Bearer claim

#universe_domain

def universe_domain() -> String
Returns
  • (String) — The universe domain of the universe this token is for

#universe_domain=

def universe_domain=(value) -> String
Parameter
  • value (String) — The universe domain of the universe this token is for
Returns
  • (String) — The universe domain of the universe this token is for