Class: OmniAuth::Strategies::Launchpad
- Inherits:
-
OAuth
- Object
- OAuth
- OmniAuth::Strategies::Launchpad
- Includes:
- OmniAuth::Strategy
- Defined in:
- lib/omniauth/strategies/launchpad.rb
Instance Method Summary collapse
-
#initialize(app, consumer_key = "babun", options = {}, &block) ⇒ Launchpad
constructor
A new instance of Launchpad.
- #raw_user_info ⇒ Object
- #request_phase ⇒ Object
Constructor Details
#initialize(app, consumer_key = "babun", options = {}, &block) ⇒ Launchpad
Returns a new instance of Launchpad.
25 26 27 28 29 |
# File 'lib/omniauth/strategies/launchpad.rb', line 25 def initialize(app, consumer_key="babun", ={}, &block) [:oauth_consumer_key] = consumer_key [:oauth_consumer_secret] = consumer_secret super(app, consumer_key, nil, , &block) end |
Instance Method Details
#raw_user_info ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/omniauth/strategies/launchpad.rb', line 31 def raw_user_info puts "before: #{@access_token.inspect}" = {:oauth_consumer_key => [:oauth_consumer_key], :realm => "https://api.launchpad.net/"} .merge!([:authorize_params]) @access_token.consumer.[:scheme] = :header info = @access_token.get('https://api.launchpad.net/devel/people/+me', {'Accept' => 'application/json'}) info = @access_token.get(info["location"], {'Accept' => 'application/json'}) @raw_user_info ||= MultiJson.load info.body end |
#request_phase ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/omniauth/strategies/launchpad.rb', line 54 def request_phase puts "Request info: #{.request_param}" = {:oauth_consumer_key => [:oauth_consumer_key], :realm => "https://api.launchpad.net/"} .merge!([:authorize_params]) request_token = consumer.get_request_token({:oauth_callback => callback_url}, ) session['oauth'] ||= {} session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret} r = Rack::Response.new if request_token.callback_confirmed? r.redirect(request_token.) else r.redirect(request_token.(:oauth_callback => callback_url)) end @request_token = request_token r.finish rescue ::Timeout::Error => e fail!(:timeout, e) rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e fail!(:service_unavailable, e) end |