Class: OmniAuth::Strategies::Blogger
- Defined in:
- lib/omniauth/strategies/oauth/blogger.rb
Overview
Authenticate to YouTube via OAuth and retrieve basic user info.
Usage: use OmniAuth::Strategies::YouTube, '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) ⇒ Blogger
constructor
A new instance of Blogger.
- #request_phase ⇒ Object
- #user_hash ⇒ Object
-
#user_info ⇒ Object
TODO: Remove contact list from hash returned to the application.
Methods inherited from OAuth
#callback_phase, #consumer, #unique_id
Constructor Details
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Blogger
Returns a new instance of Blogger.
12 13 14 15 16 17 18 19 20 |
# File 'lib/omniauth/strategies/oauth/blogger.rb', line 12 def initialize(app, consumer_key=nil, consumer_secret=nil, ={}, &block) = { :access_token_path => '/accounts/OAuthGetAccessToken', :authorize_path => '/accounts/OAuthAuthorizeToken', :request_token_path => '/accounts/OAuthGetRequestToken', :site => 'https://www.google.com', } super(app, :blogger, consumer_key, consumer_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/omniauth/strategies/oauth/blogger.rb', line 22 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
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/omniauth/strategies/oauth/blogger.rb', line 44 def request_phase request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => 'http://www.blogger.com/feeds/ http://www.google.com/m8/feeds/'}) 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
39 40 41 42 |
# File 'lib/omniauth/strategies/oauth/blogger.rb', line 39 def user_hash # Using Contact feed @user_hash ||= MultiJson.decode(@access_token.get('https://www.google.com/m8/feeds/contacts/default/full/?alt=json').body) end |
#user_info ⇒ Object
TODO: Remove contact list from hash returned to the application
32 33 34 35 36 37 |
# File 'lib/omniauth/strategies/oauth/blogger.rb', line 32 def user_info { 'uid' => user_hash['feed']['author'][0]['email']['$t'], 'nickname' => user_hash['feed']['author'][0]['name']['$t'], } end |