Class: OmniAuth::Strategies::RTM

Inherits:
Object
  • Object
show all
Includes:
OmniAuth::Strategy
Defined in:
lib/omniauth/strategies/rtm.rb

Instance Method Summary collapse

Instance Method Details

#callback_phaseObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/omniauth/strategies/rtm.rb', line 27

def callback_phase
  raise OmniAuth::NoSessionError.new("Session Expired") if session['oauth'].nil?

  rtm_auth.frob = request.params['frob']

  @token = rtm_auth.get_token
  rtm.token = @token

  resp = rtm.check_token

  @uid      = resp['auth']['user']['id']
  @nickname = resp['auth']['user']['username']
  @fullname = resp['auth']['user']['fullname']

  super
rescue ::Timeout::Error => e
  fail!(:timeout, e)
rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
  fail!(:service_unavailable, e)
rescue ::RTM::VerificationException => e
  fail!(:invalid_credentials, e)
rescue ::OmniAuth::NoSessionError => e
  fail!(:session_expired, e)
end

#request_phaseObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/omniauth/strategies/rtm.rb', line 14

def request_phase
  auth_url = rtm_auth.url :delete, :web #, "http://localhost:3000/auth/rtm/callback"

  session['oauth'] ||= {}
  session['oauth']['rtm'] = {}

  redirect(auth_url)
rescue ::Timeout::Error => e
  fail!(:timeout, e)
rescue ::Net::HTTPFatalError => e
  fail!(:service_unavailable, e)
end