googleauth - Class Google::Auth::ServiceAccountJwtHeaderCredentials (v1.12.0)

Reference documentation and code samples for the googleauth class Google::Auth::ServiceAccountJwtHeaderCredentials.

Authenticates requests using Google's Service Account credentials via JWT Header.

This class allows authorizing requests for service accounts directly from credentials from a json key file downloaded from the developer console (via 'Generate new Json Key'). It is not part of any OAuth2 flow, rather it creates a JWT and sends that as a credential.

cf Application Default Credentials

Inherits

  • Object

Methods

.make_creds

def self.make_creds(options = {})

Create a ServiceAccountJwtHeaderCredentials.

Parameters
  • json_key_io (IO) — an IO from which the JSON key can be read
  • scope (string|array|nil) — the scope(s) to access

#apply

def apply(a_hash, opts = {})

Returns a clone of a_hash updated with the authorization header

#apply!

def apply!(a_hash, opts = {})

Construct a jwt token if the JWT_AUD_URI key is present in the input hash.

The jwt token is used as the value of a 'Bearer '.

#initialize

def initialize(options = {}) -> ServiceAccountJwtHeaderCredentials

Initializes a ServiceAccountJwtHeaderCredentials.

Parameter
  • json_key_io (IO) — an IO from which the JSON key can be read
Returns

#logger

def logger()

Returns the value of attribute logger.

#logger=

def logger=(value)

Sets the attribute logger

#needs_access_token?

def needs_access_token?() -> Boolean

Duck-types the corresponding method from BaseClient

Returns
  • (Boolean)

#new_jwt_token

def new_jwt_token(jwt_aud_uri = nil, options = {})

Creates a jwt uri token.

#project_id

def project_id()

Returns the value of attribute project_id.

#quota_project_id

def quota_project_id()

Returns the value of attribute quota_project_id.

#universe_domain

def universe_domain()

Returns the value of attribute universe_domain.

#universe_domain=

def universe_domain=(value)

Sets the attribute universe_domain

#updater_proc

def updater_proc()

Returns a reference to the #apply method, suitable for passing as a closure

Constants

JWT_AUD_URI_KEY

value: :jwt_aud_uri

AUTH_METADATA_KEY

value: Google::Auth::BaseClient::AUTH_METADATA_KEY

TOKEN_CRED_URI

SIGNING_ALGORITHM

value: "RS256".freeze

EXPIRY

value: 60