Class: OmniAuth::Strategies::Surveymonkey2

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/surverymonkey2.rb

Constant Summary collapse

DEFAULT_RESPONSE_TYPE =
'code'
DEFAULT_GRANT =
'authorization_code'

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



20
21
22
23
24
25
26
27
# File 'lib/omniauth/strategies/surverymonkey2.rb', line 20

def authorize_params
  log :info, ">>>>>>>> in authorize_params"
  super.tap do |params|
    params[:response_type] ||= DEFAULT_RESPONSE_TYPE
    params[:client_id] = options[:client_id]
    params[:api_key] = options[:api_key]
  end
end

#build_access_tokenObject



39
40
41
42
43
44
45
46
47
# File 'lib/omniauth/strategies/surverymonkey2.rb', line 39

def build_access_token
  log :info, ">>>>>>>> calling build_access_token"
  verifier = request.params['code']
  log :info, ">>>>>>> code: #{verifier.inspect}"
  log :info, ">>>>> getting auth token now"
  token = client.auth_code.get_token(verifier, token_params)
  log :info, ">>>>>> token: #{token.inspect}"
  token
end

#callback_phaseObject



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/omniauth/strategies/surverymonkey2.rb', line 49

def callback_phase
  log :info, ">>>>>>>> in callback_phase"
  options[:client_options][:token_url] = "/oauth/token?api_key=#{options[:api_key]}"
  log :info, ">>>> in callback phase, calling build_access_token"
  self.access_token = build_access_token
  log :info, ">>>>>> self access token: #{self.access_token.inspect}"
  log :info, ">>>> getting ready to set auth hash"
  hash = auth_hash
  log :info, ">>>>> auth hash is: #{hash.inspect}"
  self.env['omniauth.auth'] = hash
  log :info, ">>>> calling app"
  call_app!
end

#token_paramsObject



29
30
31
32
33
34
35
36
37
# File 'lib/omniauth/strategies/surverymonkey2.rb', line 29

def token_params
  log :info, ">>>>>>> calling token params"
  super.tap do |params|
    params[:grant_type] ||= DEFAULT_GRANT
    params[:client_id] = options[:client_id]
    params[:client_secret] = options[:client_secret]
    params[:redirect_uri] = callback_url
  end
end