Class: Rack::OAuth2::Server::Token::Request

Inherits:
Abstract::Request show all
Defined in:
lib/rack/oauth2/server/token.rb

Instance Method Summary collapse

Methods inherited from Abstract::Request

#attr_missing_with_error_handling!

Constructor Details

#initialize(env) ⇒ Request

Returns a new instance of Request.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rack/oauth2/server/token.rb', line 18

def initialize(env)
  auth = Rack::Auth::Basic::Request.new(env)
  if auth.provided? && auth.basic?
    @client_id, @client_secret = auth.credentials
    super
  else
    super
    @client_secret = params['client_secret']
  end
  @grant_type = params['grant_type']
end

Instance Method Details

#profileObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rack/oauth2/server/token.rb', line 30

def profile
  case params['grant_type'].to_s
  when 'authorization_code'
    AuthorizationCode
  when 'password'
    Password
  when 'client_credentials'
    ClientCredentials
  when 'refresh_token'
    RefreshToken
  when ''
    attr_missing!
  else
    unsupported_grant_type!("'#{params['grant_type']}' isn't supported.")
  end
end