class OmniAuth::Strategies::Square
Public Instance Methods
raw_info()
click to toggle source
# File lib/omniauth/strategies/square.rb, line 29 def raw_info @raw_info ||= access_token.get('/v1/me').parsed end
Protected Instance Methods
build_access_token()
click to toggle source
# File lib/omniauth/strategies/square.rb, line 35 def build_access_token parsed_response = fetch_access_token parsed_response['expires_at'] = Time.parse(parsed_response['expires_at']).to_i parsed_response.merge!(deep_symbolize(options.auth_token_params)) connect_client = client.dup connect_client.site = options.client_options.connect_site ::OAuth2::AccessToken.from_hash(connect_client, parsed_response) end
Private Instance Methods
access_token_request_payload()
click to toggle source
# File lib/omniauth/strategies/square.rb, line 57 def access_token_request_payload params = { :code => request.params['code'], :redirect_uri => callback_url } params.merge! client.auth_code.client_params params.merge! token_params.to_hash(:symbolize_keys => true) opts = { :raise_errors => params.delete(:raise_errors), :parse => params.delete(:parse), :headers => {'Content-Type' => 'application/x-www-form-urlencoded'} } headers = params.delete(:headers) opts[:body] = params opts[:headers].merge!(headers) if headers opts end
fetch_access_token()
click to toggle source
# File lib/omniauth/strategies/square.rb, line 48 def fetch_access_token opts = access_token_request_payload response = client.request(client.options[:token_method], client.token_url, opts) parsed = response.parsed error = ::OAuth2::Error.new(response) fail(error) if opts[:raise_errors] && !(parsed.is_a?(Hash) && parsed['access_token']) parsed end
prune!(hash)
click to toggle source
# File lib/omniauth/strategies/square.rb, line 78 def prune!(hash) hash.delete_if do |_, value| prune!(value) if value.is_a?(Hash) value.nil? || (value.respond_to?(:empty?) && value.empty?) end end