Class: Doorkeeper::OAuth::TokenResponse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ TokenResponse

Returns a new instance of TokenResponse.


8
9
10
# File 'lib/doorkeeper/oauth/token_response.rb', line 8

def initialize(token)
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token


6
7
8
# File 'lib/doorkeeper/oauth/token_response.rb', line 6

def token
  @token
end

Instance Method Details

#bodyObject


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

def body
  {
    "access_token" => token.plaintext_token,
    "token_type" => token.token_type,
    "expires_in" => token.expires_in_seconds,
    "refresh_token" => token.plaintext_refresh_token,
    "scope" => token.scopes_string,
    "created_at" => token.created_at.to_i,
  }.reject { |_, value| value.blank? }
end

#headersObject


27
28
29
30
31
32
33
# File 'lib/doorkeeper/oauth/token_response.rb', line 27

def headers
  {
    "Cache-Control" => "no-store",
    "Pragma" => "no-cache",
    "Content-Type" => "application/json; charset=utf-8",
  }
end

#statusObject


23
24
25
# File 'lib/doorkeeper/oauth/token_response.rb', line 23

def status
  :ok
end