19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/omniauth/strategies/hubspot.rb', line 19
def callback_phase
if request.params['error'] || request.params['error_reason']
raise CallbackError.new(request.params['error'], request.params['error_description'] || request.params['error_reason'], request.params['error_uri'])
end
if !options.provider_ignores_state && (request.params['state'].to_s.empty? || request.params['state'] != session.delete('omniauth.state'))
raise CallbackError.new(nil, :csrf_detected)
end
hash = Hashie::Mash.new
hash.token = request.params['access_token']
hash.refresh_token = request.params['refresh_token']
hash.expires_in = request.params['expires_in']
self.access_token = hash
self.env['omniauth.auth'] = auth_hash
call_app!
rescue ::OAuth2::Error, CallbackError => e
fail!(:invalid_credentials, e)
rescue ::MultiJson::DecodeError => e
fail!(:invalid_response, e)
rescue ::Timeout::Error, ::Errno::ETIMEDOUT, Faraday::Error::TimeoutError => e
fail!(:timeout, e)
rescue ::SocketError, Faraday::Error::ConnectionFailed => e
fail!(:failed_to_connect, e)
end
|