class OmniAuth::Strategies::SageImpact

Constants

DEFAULT_GRANT
DEFAULT_RESPONSE_TYPE
INFO_URL

Public Instance Methods

authorize_params() click to toggle source

The OAuth2 client authorization parameters.

@return [OmniAuth::Strategy::Options]

Calls superclass method
# File lib/omniauth/strategies/sage_impact.rb, line 35
def authorize_params
  super.tap do |params|
    params[:response_type] ||= DEFAULT_RESPONSE_TYPE
    params[:client_id] = client.id
  end
end
raw_info() click to toggle source

Unfiltered data about the authenticating user.

@return [Hash]

# File lib/omniauth/strategies/sage_impact.rb, line 45
def raw_info
  @raw_info ||= access_token.get(INFO_URL).parsed || {}
end
token_params() click to toggle source

The OAuth2 client authentication parameters.

@return [OmniAuth::Strategy::Options]

Calls superclass method
# File lib/omniauth/strategies/sage_impact.rb, line 52
def token_params
  super.tap do |params|
    params[:grant_type] ||= DEFAULT_GRANT
    params[:client_id] = client.id
    params[:client_secret] = client.secret
  end
end

Private Instance Methods

full_name() click to toggle source
# File lib/omniauth/strategies/sage_impact.rb, line 62
def full_name
  first_name = raw_info['first_name'] || ''
  last_name = raw_info['last_name'] || ''

  "#{first_name} #{last_name}".strip || nil
end
prune!(hash) click to toggle source
# File lib/omniauth/strategies/sage_impact.rb, line 69
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
retrieved_email() click to toggle source
# File lib/omniauth/strategies/sage_impact.rb, line 76
def retrieved_email
  primary = raw_info['emails'].detect { |e| e['primary'] }
  primary ||= raw_info['emails'].first
  primary['email']
end