Module: Doorkeeper::OAuth::RequestConcern

Included in:
AuthorizationCodeRequest, ClientCredentialsRequest, PasswordAccessTokenRequest, RefreshTokenRequest
Defined in:
lib/doorkeeper/oauth/request_concern.rb

Instance Method Summary collapse

Instance Method Details

#after_successful_responseObject


44
45
# File 'lib/doorkeeper/oauth/request_concern.rb', line 44

def after_successful_response
end

#authorizeObject


4
5
6
7
8
9
10
11
12
13
14
# File 'lib/doorkeeper/oauth/request_concern.rb', line 4

def authorize
  validate
  if valid?
    before_successful_response
    @response = TokenResponse.new(access_token)
    after_successful_response
    @response
  else
    @response = ErrorResponse.from_request(self)
  end
end

#before_successful_responseObject


41
42
# File 'lib/doorkeeper/oauth/request_concern.rb', line 41

def before_successful_response
end

#default_scopesObject


24
25
26
# File 'lib/doorkeeper/oauth/request_concern.rb', line 24

def default_scopes
  server.default_scopes
end

#find_or_create_access_token(client, resource_owner_id, scopes, server) ⇒ Object


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

def find_or_create_access_token(client, resource_owner_id, scopes, server)
  @access_token = AccessToken.find_or_create_for(
    client,
    resource_owner_id,
    scopes,
    Authorization::Token.access_token_expires_in(server, client),
    server.refresh_token_enabled?)
end

#scopesObject


16
17
18
19
20
21
22
# File 'lib/doorkeeper/oauth/request_concern.rb', line 16

def scopes
  @scopes ||= if @original_scopes.present?
                OAuth::Scopes.from_string(@original_scopes)
              else
                default_scopes
              end
end

#valid?Boolean

Returns:

  • (Boolean)

28
29
30
# File 'lib/doorkeeper/oauth/request_concern.rb', line 28

def valid?
  error.nil?
end