Class: OmniAuth::Strategies::Douban
- Inherits:
-
OAuth
- Object
- OAuth
- OmniAuth::Strategies::Douban
- Defined in:
- lib/omniauth/strategies/douban.rb
Instance Method Summary collapse
- #consumer ⇒ Object
-
#initialize(*args) ⇒ Douban
constructor
A new instance of Douban.
-
#raw_info ⇒ Object
taken from github.com/intridea/omniauth/blob/0-3-stable/oa-oauth/lib/omniauth/strategies/oauth/tsina.rb#L52-67 def request_phase request_token = consumer.get_request_token(:oauth_callback => callback_url) session ||= {} session[name.to_s] = => true, ‘request_token’ => request_token.token, ‘request_secret’ => request_token.secret.
Constructor Details
#initialize(*args) ⇒ Douban
Returns a new instance of Douban.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/omniauth/strategies/douban.rb', line 9 def initialize(*args) super # taken from https://github.com/intridea/omniauth/blob/0-3-stable/oa-oauth/lib/omniauth/strategies/oauth/douban.rb#L15-21 . = { :access_token_path => '/service/auth/access_token', :authorize_path => '/service/auth/authorize', :realm => 'OmniAuth', :request_token_path => '/service/auth/request_token', :site => 'http://www.douban.com' } end |
Instance Method Details
#consumer ⇒ Object
21 22 23 24 |
# File 'lib/omniauth/strategies/douban.rb', line 21 def consumer consumer = ::OAuth::Consumer.new(.consumer_key, .consumer_secret, .) consumer end |
#raw_info ⇒ Object
taken from github.com/intridea/omniauth/blob/0-3-stable/oa-oauth/lib/omniauth/strategies/oauth/tsina.rb#L52-67 def request_phase
request_token = consumer.get_request_token(:oauth_callback => callback_url)
session['oauth'] ||= {}
session['oauth'][name.to_s] = {'callback_confirmed' => true, '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
64 65 66 67 68 |
# File 'lib/omniauth/strategies/douban.rb', line 64 def raw_info @raw_info ||= MultiJson.decode(access_token.get('http://api.douban.com/people/%40me?alt=json').body) rescue ::Errno::ETIMEDOUT raise ::Timeout::Error end |