Class: Devise::Strategies::Oauth2GrantTypeStrategy

Inherits:
Authenticatable
  • Object
show all
Defined in:
lib/devise/oauth2_providable/strategies/oauth2_grant_type_strategy.rb

Instance Method Summary collapse

Instance Method Details

#clientObject



14
15
16
17
18
19
# File 'lib/devise/oauth2_providable/strategies/oauth2_grant_type_strategy.rb', line 14

def client
  return @client if @client
  @client = Devise::Oauth2Providable::Client.find_by_identifier params[:client_id]
  env[Devise::Oauth2Providable::CLIENT_ENV_REF] = @client
  @client
end

#grant_typeObject

defined by subclass



11
12
# File 'lib/devise/oauth2_providable/strategies/oauth2_grant_type_strategy.rb', line 11

def grant_type
end

#oauth_error!(error_code = :invalid_request, description = nil) ⇒ Object

return custom error response in accordance with the oauth spec see tools.ietf.org/html/draft-ietf-oauth-v2-16#section-4.3



22
23
24
25
26
# File 'lib/devise/oauth2_providable/strategies/oauth2_grant_type_strategy.rb', line 22

def oauth_error!(error_code = :invalid_request, description = nil)
  body = {:error => error_code}
  body[:error_description] = description if description
  custom! [400, {'Content-Type' => 'application/json'}, [body.to_json]]
end

#valid?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/devise/oauth2_providable/strategies/oauth2_grant_type_strategy.rb', line 6

def valid?
  params[:controller] == 'devise/oauth2_providable/tokens' && request.post? && params[:grant_type] == grant_type
end