Class: Doorkeeper::DeviceAuthorizationGrant::OAuth::DeviceAuthorizationRequest

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

Overview

Doorkeeper request object for handling OAuth 2.0 Device Authorization Requests.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, client, host_name, parameters = {}) ⇒ DeviceAuthorizationRequest

Returns a new instance of DeviceAuthorizationRequest.

Parameters:

  • server
  • client
  • host_name (String)
  • parameters (Hash) (defaults to: {})


21
22
23
24
25
26
27
# File 'lib/doorkeeper/device_authorization_grant/oauth/device_authorization_request.rb', line 21

def initialize(server, client, host_name, parameters = {}) # rubocop:disable Style/OptionHash
  super()
  @server = server
  @client = client
  @host_name = host_name
  @original_scopes = parameters[:scope]
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



10
11
12
# File 'lib/doorkeeper/device_authorization_grant/oauth/device_authorization_request.rb', line 10

def client
  @client
end

#host_nameString

Returns:

  • (String)


13
14
15
# File 'lib/doorkeeper/device_authorization_grant/oauth/device_authorization_request.rb', line 13

def host_name
  @host_name
end

#serverObject

Returns the value of attribute server.



10
11
12
# File 'lib/doorkeeper/device_authorization_grant/oauth/device_authorization_request.rb', line 10

def server
  @server
end

Instance Method Details

#authorizeDeviceAuthorizationResponse, Doorkeeper::OAuth::ErrorResponse

Returns:



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

def authorize
  validate

  @response =
    if valid?
      destroy_expired_device_grants!
      create_successful_response
    else
      Doorkeeper::OAuth::ErrorResponse.from_request(self)
    end
end