Class: OmniAuth::Shootproof::Client
- Inherits:
-
OAuth2::Client
- Object
- OAuth2::Client
- OmniAuth::Shootproof::Client
- Defined in:
- lib/omniauth/shootproof/client.rb
Overview
rubocop:disable Metrics/ClassLength
Instance Method Summary collapse
-
#get_token(params, access_token_opts = {}, access_token_class = ::OAuth2::AccessToken) ⇒ AccessToken
Initializes an AccessToken by making a request to the token endpoint.
-
#redirection_params ⇒ Hash
The redirect_uri parameters, if configured.
Instance Method Details
#get_token(params, access_token_opts = {}, access_token_class = ::OAuth2::AccessToken) ⇒ AccessToken
Initializes an AccessToken by making a request to the token endpoint
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/omniauth/shootproof/client.rb', line 13 def get_token(params, access_token_opts = {}, access_token_class = ::OAuth2::AccessToken) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength params = ::OAuth2::Authenticator.new(id, secret, [:auth_scheme]).apply(params) opts = {:raise_errors => [:raise_errors], :parse => params.delete(:parse)} headers = params.delete(:headers) || {} if [:token_method] == :post opts[:params] = params opts[:params].merge!(redirection_params) opts[:headers] = {'Content-Type' => 'application/x-www-form-urlencoded'} else error = Error.new('Must Be POST') raise(error) end opts[:headers].merge!(headers) response = request([:token_method], token_url, opts) if [:raise_errors] && !(response.parsed.is_a?(Hash) && response.parsed['access_token']) error = Error.new(response) raise(error) end access_token_class.from_hash(self, response.parsed.merge(access_token_opts)) end |
#redirection_params ⇒ Hash
The redirect_uri parameters, if configured
The redirect_uri query parameter is OPTIONAL (though encouraged) when requesting authorization. If it is provided at authorization time it MUST also be provided with the token exchange request.
Providing the :redirect_uri to the OAuth2::Client instantiation will take care of managing this.
50 51 52 53 54 55 56 |
# File 'lib/omniauth/shootproof/client.rb', line 50 def redirection_params if [:redirect_uri] {:redirect_uri => [:redirect_uri]} else {} end end |