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/mac.rb,
lib/rack/oauth2/access_token/bearer.rb,
lib/rack/oauth2/access_token/legacy.rb,
lib/rack/oauth2/access_token/mac/verifier.rb,
lib/rack/oauth2/access_token/authenticator.rb,
lib/rack/oauth2/access_token/mac/signature.rb,
lib/rack/oauth2/access_token/mac/sha256_hex_verifier.rb

Direct Known Subclasses

Bearer, Legacy, MAC

Defined Under Namespace

Classes: Authenticator, Bearer, Legacy, MAC

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
20
21
22
# 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
  @httpclient = Rack::OAuth2.http_client("#{self.class} (#{VERSION})") do |config|
    config.request_filter << Authenticator.new(self)
  end
  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

#token_response(options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/rack/oauth2/access_token.rb', line 24

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