Sha256: 122665417f497212f5586576b8c0398c140715bc56eb9c5fd477c37ca48fecda
Contents?: true
Size: 924 Bytes
Versions: 2
Compression:
Stored size: 924 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 @client ||= Devise::Oauth2Providable::Client.find_by_identifier params[:client_id] env['oauth2.client'] = @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
2 entries across 2 versions & 1 rubygems