class OmniAuth::Strategies::Dailycred

Constants

AUTH_PARAMS

allows parameters to be passed through

Public Instance Methods

authorize_params() click to toggle source
Calls superclass method
# File lib/omniauth/strategies/dailycred.rb, line 33
def authorize_params
  super.tap do |params|
    params[:state] ||= {}
  end
end
old_request_phase()
Alias for: request_phase
request_phase() click to toggle source

this step allows auth_params to be added to the url

# File lib/omniauth/strategies/dailycred.rb, line 40
def request_phase
  p session['omniauth.state']
  OmniAuth::Strategies::Dailycred::AUTH_PARAMS.each do |param|
    val = session['omniauth.params'][param]
    if val && !val.empty?
      options[:authorize_params] ||= {}
      options[:authorize_params].merge!(param => val)
    end
  end
  old_request_phase
end
Also aliased as: old_request_phase

Private Instance Methods

user() click to toggle source

This is the phase where the gem calls me.json, which returns information about the user

# File lib/omniauth/strategies/dailycred.rb, line 55
def user
  return @duser if !@duser.nil?
  connection = Faraday::Connection.new options.client_options[:site], :ssl => options.client_options[:ssl]
  response = connection.get("/graph/me.json?access_token=#{access_token.token}")
  json = JSON.parse(response.body)
  pp json if options[:verbose]
  @duser = {'token' => access_token.token}
  @duser['provider'] = 'dailycred'
  @duser['uid'] =  json['id'] || json['user_id']
  json.each do |k,v|
    @duser[k] = v
  end
  json["identities"].each do |k, v|
    @duser[k] = v
    @duser[k][:access_token] = json["access_tokens"][k]
  end if !json["identities"].nil?
  pp @duser if options[:verbose]
  created = json['created'] / 1000
  @duser['created'] = DateTime.strptime(created.to_s, '%s')
  @duser.delete("id")

  @duser
end