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

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

Instance Attribute Summary collapse

Class Method 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

Class Method Details

.access_token_expires_in(server, pre_auth) ⇒ Object


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

def self.access_token_expires_in(server, pre_auth)
  custom_expiration = server.
    custom_access_token_expires_in.call(pre_auth)

  if custom_expiration
    custom_expiration
  else
    server.access_token_expires_in
  end
end

Instance Method Details

#configurationObject


41
42
43
# File 'lib/doorkeeper/oauth/authorization/token.rb', line 41

def configuration
  Doorkeeper.configuration
end

#issue_tokenObject


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

def issue_token
  @token ||= AccessToken.find_or_create_for(
    pre_auth.client,
    resource_owner.id,
    pre_auth.scopes,
    self.class.access_token_expires_in(configuration, pre_auth),
    false
  )
end

#native_redirectObject


33
34
35
36
37
38
39
# File 'lib/doorkeeper/oauth/authorization/token.rb', line 33

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