Class: OmniAuth::Strategies::Surveymonkey
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Surveymonkey
- Defined in:
- lib/omniauth/strategies/surveymonkey.rb
Constant Summary collapse
- DEFAULT_RESPONSE_TYPE =
'code'
- DEFAULT_GRANT =
'authorization_code'
Instance Method Summary collapse
- #authorize_params ⇒ Object
- #build_access_token ⇒ Object
- #callback_path ⇒ Object
- #callback_phase ⇒ Object
- #callback_url ⇒ Object
- #full_host ⇒ Object
- #raw_info ⇒ Object
- #script_name ⇒ Object
- #token_params ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/omniauth/strategies/surveymonkey.rb', line 32 def super.tap do |params| params[:response_type] ||= DEFAULT_RESPONSE_TYPE params[:client_id] = [:client_id] params[:api_key] = [:api_key] end end |
#build_access_token ⇒ Object
40 41 42 43 |
# File 'lib/omniauth/strategies/surveymonkey.rb', line 40 def build_access_token verifier = request.params['code'] token = client.auth_code.get_token(verifier, token_params) end |
#callback_path ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'lib/omniauth/strategies/surveymonkey.rb', line 92 def callback_path @callback_path ||= begin path = [:callback_path] if [:callback_path].is_a?(String) path ||= current_path if [:callback_path].respond_to?(:call) && [:callback_path].call(env) path ||= custom_path(:request_path) path ||= "#{path_prefix}/#{name}/callback" path end end |
#callback_phase ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/omniauth/strategies/surveymonkey.rb', line 45 def callback_phase [:client_options][:token_url] = "/oauth/token?api_key=#{[:api_key]}" self.access_token = build_access_token self.env['omniauth.auth'] = auth_hash call_app! rescue ::OAuth2::Error, CallbackError => e fail!(:invalid_credentials, e) rescue ::Timeout::Error, ::Errno::ETIMEDOUT => e fail!(:timeout, e) rescue ::SocketError => e fail!(:failed_to_connect, e) end |
#callback_url ⇒ Object
68 69 70 |
# File 'lib/omniauth/strategies/surveymonkey.rb', line 68 def callback_url full_host + script_name + callback_path end |
#full_host ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/omniauth/strategies/surveymonkey.rb', line 72 def full_host case OmniAuth.config.full_host when String OmniAuth.config.full_host when Proc OmniAuth.config.full_host.call(env) else if request.scheme && request.url.match(URI::ABS_URI) uri = URI.parse(request.url.gsub(/\?.*$/, '')) uri.path = '' uri.scheme = 'https' if ssl? uri.to_s end end end |
#raw_info ⇒ Object
28 29 30 |
# File 'lib/omniauth/strategies/surveymonkey.rb', line 28 def raw_info @raw_info ||= access_token.get('/v3/users/me').parsed end |
#script_name ⇒ Object
88 89 90 |
# File 'lib/omniauth/strategies/surveymonkey.rb', line 88 def script_name @env['SCRIPT_NAME'] || '' end |
#token_params ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/omniauth/strategies/surveymonkey.rb', line 59 def token_params super.tap do |params| params[:grant_type] ||= DEFAULT_GRANT params[:client_id] = [:client_id] params[:client_secret] = [:client_secret] params[:redirect_uri] = callback_url end end |