Class: Doorkeeper::OAuth::ClientCredentialsRequest

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

Instance Attribute Summary collapse

Attributes inherited from BaseRequest

#grant_type, #server

Instance Method Summary collapse

Methods inherited from BaseRequest

#after_successful_response, #authorize, #before_successful_response, #find_or_create_access_token, #scopes

Methods included from Validations

#validate

Constructor Details

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

Returns a new instance of ClientCredentialsRequest.



10
11
12
13
14
15
16
17
18
19
# File 'lib/doorkeeper/oauth/client_credentials_request.rb', line 10

def initialize(server, client, parameters = {})
  super()
  @client = client
  @server = server
  @response = nil
  @grant_type = Doorkeeper::OAuth::CLIENT_CREDENTIALS
  @original_scopes = parameters[:scope]
  @raw_resource_indicators = parameters[:resource]
  @parameters = parameters.except(:scope, :resource)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



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

def client
  @client
end

#original_scopesObject (readonly)

Returns the value of attribute original_scopes.



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

def original_scopes
  @original_scopes
end

#parametersObject (readonly)

Returns the value of attribute parameters.



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

def parameters
  @parameters
end

#responseObject (readonly) Also known as: error_response

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#access_tokenObject



21
22
23
# File 'lib/doorkeeper/oauth/client_credentials_request.rb', line 21

def access_token
  issuer.token
end

#errorObject



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

def error
  @resource_indicator_error || issuer.error
end

#issuerObject



29
30
31
32
33
34
# File 'lib/doorkeeper/oauth/client_credentials_request.rb', line 29

def issuer
  @issuer ||= ClientCredentials::Issuer.new(
    server,
    ClientCredentials::Validator.new(server, self),
  )
end