Class: Doorkeeper::DeviceAuthorizationGrant::OAuth::DeviceAuthorizationResponse

Inherits:
OAuth::BaseResponse
  • Object
show all
Defined in:
lib/doorkeeper/device_authorization_grant/oauth/device_authorization_response.rb

Overview

Doorkeeper response object for handling OAuth 2.0 Device Authorization Responses.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device_grant, host_name) ⇒ DeviceAuthorizationResponse

Returns a new instance of DeviceAuthorizationResponse.

Parameters:



18
19
20
21
22
# File 'lib/doorkeeper/device_authorization_grant/oauth/device_authorization_response.rb', line 18

def initialize(device_grant, host_name)
  super()
  @device_grant = device_grant
  @host_name = host_name
end

Instance Attribute Details

#device_grantDeviceGrant

Returns:



11
12
13
# File 'lib/doorkeeper/device_authorization_grant/oauth/device_authorization_response.rb', line 11

def device_grant
  @device_grant
end

#host_nameString

Returns:

  • (String)


14
15
16
# File 'lib/doorkeeper/device_authorization_grant/oauth/device_authorization_response.rb', line 14

def host_name
  @host_name
end

Instance Method Details

#bodyHash

Returns:

  • (Hash)


30
31
32
33
34
35
36
37
38
39
# File 'lib/doorkeeper/device_authorization_grant/oauth/device_authorization_response.rb', line 30

def body
  {
    'device_code' => device_grant.plaintext_device_code,
    'user_code' => device_grant.user_code,
    'verification_uri' => verification_uri,
    'verification_uri_complete' => verification_uri_complete,
    'expires_in' => device_grant.expires_in,
    'interval' => interval
  }.reject { |_, value| value.blank? } # rubocop:disable Rails/CompactBlank does not exist in Rails < 6.1
end

#headersHash

Returns:

  • (Hash)


42
43
44
45
46
47
48
# File 'lib/doorkeeper/device_authorization_grant/oauth/device_authorization_response.rb', line 42

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

#statusSymbol

Returns:

  • (Symbol)


25
26
27
# File 'lib/doorkeeper/device_authorization_grant/oauth/device_authorization_response.rb', line 25

def status
  :ok
end