Class: Rack::OAuth2::AccessToken

Inherits:
Object
  • Object
show all
Includes:
AttrOptional, AttrRequired
Defined in:
lib/rack/oauth2/access_token.rb,
lib/rack/oauth2/access_token/mtls.rb,
lib/rack/oauth2/access_token/bearer.rb,
lib/rack/oauth2/access_token/authenticator.rb

Direct Known Subclasses

Bearer

Defined Under Namespace

Classes: Authenticator, Bearer, MTLS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ AccessToken

Returns a new instance of AccessToken.



12
13
14
15
16
17
18
19
# File 'lib/rack/oauth2/access_token.rb', line 12

def initialize(attributes = {})
  (required_attributes + optional_attributes).each do |key|
    self.send :"#{key}=", attributes[key]
  end
  @raw_attributes = attributes
  @token_type = self.class.name.demodulize.underscore.to_sym
  attr_missing!
end

Instance Attribute Details

#raw_attributesObject

Returns the value of attribute raw_attributes.



7
8
9
# File 'lib/rack/oauth2/access_token.rb', line 7

def raw_attributes
  @raw_attributes
end

Instance Method Details

#http_clientObject



21
22
23
24
25
# File 'lib/rack/oauth2/access_token.rb', line 21

def http_client
  @http_client ||= Rack::OAuth2.http_client("#{self.class} (#{VERSION})") do |faraday|
    Authenticator.new(self).authenticate(faraday)
  end
end

#token_response(options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/rack/oauth2/access_token.rb', line 27

def token_response(options = {})
  {
    access_token: access_token,
    refresh_token: refresh_token,
    token_type: token_type,
    expires_in: expires_in,
    scope: Array(scope).join(' ')
  }
end