class Armrest::Api::Main

Public Instance Methods

authorization() click to toggle source
# File lib/armrest/api/main.rb, line 16
def authorization
  creds = @@creds_cache[resource]
  if creds && Time.now < Time.at(creds['expires_on'].to_i)
    return bearer_token(creds)
  end

  provider = Armrest::Auth.new(@options).provider
  if provider
    creds = provider.creds
    @@creds_cache[resource] = creds
    bearer_token(creds)
  end
end
bearer_token(creds) click to toggle source
# File lib/armrest/api/main.rb, line 30
def bearer_token(creds)
  "#{creds['token_type']} #{creds['access_token']}"
end
headers() click to toggle source
# File lib/armrest/api/main.rb, line 3
def headers
  {
    "Authorization" => authorization,
    "Content-Type" => "application/json",
  }
end