class Rack::OAuth2::Server::Token

Public Instance Methods

call(env) click to toggle source
# File lib/rack/oauth2/server/token.rb, line 7
def call(env)
  request = Request.new(env)
  grant_type_for(request).new(&@authenticator).call(env).finish
rescue Rack::OAuth2::Server::Abstract::Error => e
  e.finish
end

Private Instance Methods

extensions() click to toggle source
# File lib/rack/oauth2/server/token.rb, line 35
def extensions
  Extension.constants.sort.collect do |key|
    Extension.const_get key
  end
end
grant_type_for(request) click to toggle source
# File lib/rack/oauth2/server/token.rb, line 16
def grant_type_for(request)
  case request.grant_type
  when 'authorization_code'
    AuthorizationCode
  when 'password'
    Password
  when 'client_credentials'
    ClientCredentials
  when 'refresh_token'
    RefreshToken
  when ''
    request.attr_missing!
  else
    extensions.detect do |extension|
      extension.grant_type_for? request.grant_type
    end || request.unsupported_grant_type!
  end
end