Sha256: c6943078376a968e2cd08af967523fa7dead9f99db741df7fbfe2fbf7534c7a0
Contents?: true
Size: 981 Bytes
Versions: 5
Compression:
Stored size: 981 Bytes
Contents
require 'devise/strategies/base' module Devise module Strategies class Oauth2GrantTypeStrategy < Authenticatable def valid? params[:controller] == 'devise/oauth2_providable/tokens' && request.post? && params[:grant_type] == grant_type end # defined by subclass def grant_type end 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 # return custom error response in accordance with the oauth spec # see http://tools.ietf.org/html/draft-ietf-oauth-v2-16#section-4.3 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 end end end
Version data entries
5 entries across 5 versions & 1 rubygems