Class: OmniAuth::Strategies::Auth
- Inherits:
-
Object
- Object
- OmniAuth::Strategies::Auth
- Includes:
- OmniAuth::Strategy
- Defined in:
- lib/omniauth/strategies/auth.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
Instance Method Summary collapse
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
18 19 20 |
# File 'lib/omniauth/strategies/auth.rb', line 18 def access_token @access_token end |
Instance Method Details
#callback_phase ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/omniauth/strategies/auth.rb', line 44 def callback_phase raise OmniAuth::NoSessionError.new("Session Expired") if session['oauth'].nil? request_token = ::OAuth::RequestToken.new(consumer, session['oauth'][name.to_s].delete('request_token'), session['oauth'][name.to_s].delete('request_secret')) opts = {} if session['oauth'][name.to_s]['callback_confirmed'] opts[:oauth_verifier] = request['oauth_verifier'] else opts[:oauth_callback] = callback_url end @access_token = request_token.get_access_token(opts) super rescue ::Timeout::Error => e fail!(:timeout, e) rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e fail!(:service_unavailable, e) rescue ::OAuth::Unauthorized => e fail!(:invalid_credentials, e) rescue ::MultiJson::DecodeError => e fail!(:invalid_response, e) rescue ::OmniAuth::NoSessionError => e fail!(:session_expired, e) end |
#consumer ⇒ Object
20 21 22 23 24 25 |
# File 'lib/omniauth/strategies/auth.rb', line 20 def consumer consumer = ::OAuth::Consumer.new(.consumer_key, .consumer_secret, .) consumer.http.open_timeout = .open_timeout if .open_timeout consumer.http.read_timeout = .read_timeout if .read_timeout consumer end |
#request_phase ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/omniauth/strategies/auth.rb', line 27 def request_phase request_token = consumer.get_request_token(:oauth_callback => callback_url) session['oauth'] ||= {} session['oauth'][name.to_s] = {'callback_confirmed' => [:callback_confirmed] || request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret} if request_token.callback_confirmed? redirect request_token.([:authorize_params]) else redirect request_token.([:authorize_params].merge(:oauth_callback => callback_url)) end rescue ::Timeout::Error => e fail!(:timeout, e) rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e fail!(:service_unavailable, e) end |