Class: OmniAuth::Strategies::Orkut
- Defined in:
- lib/omniauth/strategies/oauth/orkut.rb
Overview
Authenticate to Orkut via OAuth and retrieve basic user info.
Usage:
use OmniAuth::Strategies::Orkut, 'consumerkey', 'consumersecret'
Instance Attribute Summary
Attributes inherited from OAuth
#consumer_key, #consumer_options, #consumer_secret, #name
Instance Method Summary collapse
- #auth_hash ⇒ Object
-
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Orkut
constructor
A new instance of Orkut.
- #request_phase ⇒ Object
- #user_hash ⇒ Object
- #user_info ⇒ Object
Methods inherited from OAuth
#callback_phase, #consumer, #unique_id
Constructor Details
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Orkut
Returns a new instance of Orkut.
14 15 16 17 18 19 20 21 22 |
# File 'lib/omniauth/strategies/oauth/orkut.rb', line 14 def initialize(app, consumer_key = nil, consumer_secret = nil, = {}, &block) = { :site => 'https://www.google.com', :request_token_path => '/accounts/OAuthGetRequestToken', :access_token_path => '/accounts/OAuthGetAccessToken', :authorize_path => '/accounts/OAuthAuthorizeToken' } super(app, :orkut, consumer_key, consumer_secret, , ) end |
Instance Method Details
#auth_hash ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/omniauth/strategies/oauth/orkut.rb', line 24 def auth_hash ui = user_info OmniAuth::Utils.deep_merge(super, { 'uid' => ui['uid'], 'user_info' => ui, 'extra' => {'user_hash' => user_hash} }) end |
#request_phase ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/omniauth/strategies/oauth/orkut.rb', line 47 def request_phase request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => 'http://orkut.gmodules.com/social/rest'}) 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 r.finish end |
#user_hash ⇒ Object
43 44 45 |
# File 'lib/omniauth/strategies/oauth/orkut.rb', line 43 def user_hash @user_hash ||= MultiJson.decode(@access_token.get("http://www.orkut.com/social/rest/people/@me/@self").body) end |
#user_info ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/omniauth/strategies/oauth/orkut.rb', line 33 def user_info entry = user_hash['entry'] { 'uid' => entry['id'], 'first_name' => entry['name']['givenName'], 'last_name' => entry['name']['familyName'], 'image' => entry['thumbnailUrl'] } end |