Class: OmniAuth::Strategies::Surveymonkey2

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/surveymonkey2.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
# File 'lib/omniauth/strategies/surveymonkey2.rb', line 20

def 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



37
38
39
40
# File 'lib/omniauth/strategies/surveymonkey2.rb', line 37

def build_access_token
  verifier = request.params['code']
  token = client.auth_code.get_token(verifier, token_params)
end

#callback_phaseObject



42
43
44
45
46
47
# File 'lib/omniauth/strategies/surveymonkey2.rb', line 42

def callback_phase
  options[:client_options][:token_url] = "/oauth/token?api_key=#{options[:api_key]}"
  self.access_token = build_access_token
  self.env['omniauth.auth'] = auth_hash
  call_app!
end

#token_paramsObject



28
29
30
31
32
33
34
35
# File 'lib/omniauth/strategies/surveymonkey2.rb', line 28

def 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