Class: Grape::OAuth2::Generators::Token
- Defined in:
- lib/grape_oauth2/generators/token.rb
Overview
OAuth2 Token generator class. Processes the request by required Grant Type and builds the response.
Constant Summary collapse
- STRATEGY_CLASSES =
Grant type => OAuth2 strategy class
{ password: Grape::OAuth2::Strategies::Password, client_credentials: Grape::OAuth2::Strategies::ClientCredentials, refresh_token: Grape::OAuth2::Strategies::RefreshToken }.freeze
Class Method Summary collapse
-
.generate_for(env, &_block) ⇒ Grape::OAuth2::Responses::Token
Generates Token Response based on the request.
Methods inherited from Base
Class Method Details
.generate_for(env, &_block) ⇒ Grape::OAuth2::Responses::Token
Generates Token Response based on the request.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/grape_oauth2/generators/token.rb', line 19 def generate_for(env, &_block) token = Rack::OAuth2::Server::Token.new do |request, response| request.unsupported_grant_type! unless allowed_grants.include?(request.grant_type.to_s) if block_given? yield request, response else execute_default(request, response) end end Grape::OAuth2::Responses::Token.new(token.call(env)) end |