class Google::Auth::IAMCredentials

Authenticates requests using IAM credentials.

Constants

SELECTOR_KEY
TOKEN_KEY

Public Class Methods

new(selector, token) click to toggle source

Initializes an IAMCredentials.

@param selector the IAM selector. @param token the IAM token.

# File lib/googleauth/iam.rb, line 47
def initialize(selector, token)
  raise TypeError unless selector.is_a? String
  raise TypeError unless token.is_a? String
  @selector = selector
  @token = token
end

Public Instance Methods

apply(a_hash) click to toggle source

Returns a clone of a_hash updated with the authoriation header

# File lib/googleauth/iam.rb, line 62
def apply(a_hash)
  a_copy = a_hash.clone
  apply!(a_copy)
  a_copy
end
apply!(a_hash) click to toggle source

Adds the credential fields to the hash.

# File lib/googleauth/iam.rb, line 55
def apply!(a_hash)
  a_hash[SELECTOR_KEY] = @selector
  a_hash[TOKEN_KEY] = @token
  a_hash
end
updater_proc() click to toggle source

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

# File lib/googleauth/iam.rb, line 70
def updater_proc
  lambda(&method(:apply))
end