class Icalia::Artanis::ClientAuth

Attributes

access_token[RW]
created_at[RW]
token_type[RW]

Public Class Methods

fetch() click to toggle source
# File lib/icalia/artanis/client_auth.rb, line 50
def self.fetch
  store.fetch 'my-artanis-client-token' do
    response = http.post do |req|
      req.url '/oauth/token'
      req.headers['Authorization'] = client_credentials_authorization_header
      req.params['grant_type'] = 'client_credentials'
    end
    # Return a new instance of the Client Auth:
    new ActiveSupport::JSON.decode(response.body)
  end
end

Public Instance Methods

==(other) click to toggle source
# File lib/icalia/artanis/client_auth.rb, line 17
def ==(other)
  other.is_a?(self.class) && other.access_token == access_token
end
created_at=(value) click to toggle source
# File lib/icalia/artanis/client_auth.rb, line 12
def created_at=(value)
  value = Time.at(value) if value.is_a? Integer
  @created_at = value
end
to_authorization_header() click to toggle source
# File lib/icalia/artanis/client_auth.rb, line 25
def to_authorization_header
  "Bearer #{to_s}"
end
to_s() click to toggle source
# File lib/icalia/artanis/client_auth.rb, line 21
def to_s
  access_token
end