class Icasework::Token::Bearer

Generate access token for Bearer authorisation header

Public Class Methods

generate() click to toggle source
# File lib/icasework/token/bearer.rb, line 10
def generate
  new Icasework::Resource.token(payload).data
rescue RequestError, ResponseError => e
  raise AuthenticationError, e.message
end
new(data) click to toggle source
# File lib/icasework/token/bearer.rb, line 26
def initialize(data)
  @access_token = data.fetch(:access_token)
  @token_type = data.fetch(:token_type)
  @expires_in = data.fetch(:expires_in)
end

Private Class Methods

payload() click to toggle source
# File lib/icasework/token/bearer.rb, line 18
def payload
  {
    grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
    assertion: Icasework::Token::JWT.generate
  }
end

Public Instance Methods

to_s() click to toggle source
# File lib/icasework/token/bearer.rb, line 32
def to_s
  @access_token
end