class OmniAuth::Strategies::SurveyMonkey
Public Instance Methods
callback_phase()
click to toggle source
Calls superclass method
# File lib/omniauth-surveymonkey/omniauth/strategies/surveymonkey.rb, line 16 def callback_phase connection = ::Faraday.new url: 'https://api.surveymonkey.net' do |faraday| faraday.request :url_encoded faraday.response :logger faraday.adapter ::Faraday.default_adapter end form_fields = { client_id: options.client_id, client_secret: options.client_secret, code: request.params['code'], redirect_uri: (full_host + callback_path), grant_type: 'authorization_code' } response = connection.post "/oauth/token?api_key=#{options.api_key}", form_fields json = ::MultiJson.load response.body options.access_token = json['access_token'] if options.access_token connection.authorization :Bearer, options.access_token info = connection.get "/v3/users/me?api_key=#{options.api_key}" json = ::MultiJson.load info.body options.username = json['username'] options.first_name = json['first_name'] options.last_name = json['last_name'] options.account_type = json['account_type'] options.language = json['language'] options.email = json['email'] options.surveymonkey_id = json['id'].to_i end super end
request_phase()
click to toggle source
# File lib/omniauth-surveymonkey/omniauth/strategies/surveymonkey.rb, line 11 def request_phase hash = { client_id: options.client_id, api_key: options.api_key, redirect_uri: callback_url, response_type: 'code' } redirect "#{options.url}?#{hash.to_query}" end