Class: Doorkeeper::OAuth::Authorization::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/doorkeeper/oauth/authorization/token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pre_auth, resource_owner) ⇒ Token

Returns a new instance of Token.



7
8
9
10
# File 'lib/doorkeeper/oauth/authorization/token.rb', line 7

def initialize(pre_auth, resource_owner)
  @pre_auth       = pre_auth
  @resource_owner = resource_owner
end

Instance Attribute Details

#pre_authObject

Returns the value of attribute pre_auth.



5
6
7
# File 'lib/doorkeeper/oauth/authorization/token.rb', line 5

def pre_auth
  @pre_auth
end

#resource_ownerObject

Returns the value of attribute resource_owner.



5
6
7
# File 'lib/doorkeeper/oauth/authorization/token.rb', line 5

def resource_owner
  @resource_owner
end

#tokenObject

Returns the value of attribute token.



5
6
7
# File 'lib/doorkeeper/oauth/authorization/token.rb', line 5

def token
  @token
end

Instance Method Details

#configurationObject



22
23
24
# File 'lib/doorkeeper/oauth/authorization/token.rb', line 22

def configuration
  Doorkeeper.configuration
end

#issue_tokenObject



12
13
14
15
16
17
18
19
20
# File 'lib/doorkeeper/oauth/authorization/token.rb', line 12

def issue_token
  @token ||= AccessToken.create!({
    :application_id    => pre_auth.client.id,
    :resource_owner_id => resource_owner.id,
    :scopes            => pre_auth.scopes.to_s,
    :ttl        => configuration.access_token_expires_in,
    :use_refresh_token => false
  })
end