Method: Google::Auth::ServiceAccountJwtHeaderCredentials#apply!

Defined in:
lib/googleauth/service_account_jwt_header.rb

#apply!(a_hash, opts = {}) ⇒ Object

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 '.

[View source]

109
110
111
112
113
114
115
116
117
118
119
# File 'lib/googleauth/service_account_jwt_header.rb', line 109

def apply! a_hash, opts = {}
  jwt_aud_uri = a_hash.delete JWT_AUD_URI_KEY
  return a_hash if jwt_aud_uri.nil? && @scope.nil?
  jwt_token = new_jwt_token jwt_aud_uri, opts
  a_hash[AUTH_METADATA_KEY] = "Bearer #{jwt_token}"
  logger&.debug do
    hash = Digest::SHA256.hexdigest jwt_token
    Google::Logging::Message.from message: "Sending JWT auth token. (sha256:#{hash})"
  end
  a_hash
end