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



30
31
32
# File 'lib/doorkeeper/oauth/authorization/token.rb', line 30

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,
    expires_in: configuration.access_token_expires_in,
    use_refresh_token: false
  )
end

#native_redirectObject



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

def native_redirect
  {
    controller: 'doorkeeper/token_info',
    action: :show,
    access_token: token.token
  }
end