Class: OAuth2::Rack::Authorization::Password::AccessTokenIssuer
- Inherits:
-
Object
- Object
- OAuth2::Rack::Authorization::Password::AccessTokenIssuer
- Defined in:
- lib/oauth2/rack/authorization/password/access_token_issuer.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = {}, &issuer) ⇒ AccessTokenIssuer
constructor
A new instance of AccessTokenIssuer.
Constructor Details
#initialize(app, opts = {}, &issuer) ⇒ AccessTokenIssuer
Returns a new instance of AccessTokenIssuer.
6 7 8 9 10 |
# File 'lib/oauth2/rack/authorization/password/access_token_issuer.rb', line 6 def initialize(app, opts = {}, &issuer) @app = app @issuer = issuer || opts[:issuer] end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/oauth2/rack/authorization/password/access_token_issuer.rb', line 12 def call(env) resource_owner = env['oauth2.resource_owner'] unless resource_owner return error_response(:error => 'invalid_grant') end request = Rack::Request.new(env) unless request['grant_type'] == 'password' return error_response(:error => 'invalid_request') end # oauth2.client is set in client authentication access_token = find_acccess_token(:grant_type => 'password', :resource_owner => resource_owner, :client => env['oauth2.client'], :scope => request['scope']) if access_token['error'] error_response(access_token) else access_token['token_type'] ||= 'bearer' successful_response(access_token) end end |