Class: OAuth2::Rack::Authorization::ClientCredentials::AccessTokenIssuer
- Inherits:
-
Object
- Object
- OAuth2::Rack::Authorization::ClientCredentials::AccessTokenIssuer
- Defined in:
- lib/oauth2/rack/authorization/client_credentials/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/client_credentials/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 |
# File 'lib/oauth2/rack/authorization/client_credentials/access_token_issuer.rb', line 12 def call(env) client = env['oauth2.client'] unless client return error_response(:error => 'invalid_client') end request = Rack::Request.new(env) unless request['grant_type'] == 'client_credentials' return error_response(:error => 'invalid_request') end access_token = find_acccess_token(:grant_type => 'client_credentials', :client => client, :scope => request['scope']) if access_token['error'] error_response(access_token) else access_token['token_type'] ||= 'bearer' successful_response(access_token) end end |