Class: OmniAuth::Strategies::Tumblr
- Defined in:
- lib/omniauth/strategies/oauth/tumblr.rb
Overview
Authenticate to Tumblr via OAuth and retrieve basic user information.
Usage: use OmniAuth::Strategies::Tumblr, '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) ⇒ Tumblr
constructor
A new instance of Tumblr.
- #user ⇒ Object
- #user_hash ⇒ Object
- #user_info ⇒ Object
Methods inherited from OAuth
#callback_phase, #consumer, #request_phase, #unique_id
Constructor Details
#initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block) ⇒ Tumblr
Returns a new instance of Tumblr.
12 13 14 15 16 17 18 |
# File 'lib/omniauth/strategies/oauth/tumblr.rb', line 12 def initialize(app, consumer_key=nil, consumer_secret=nil, ={}, &block) = { :site => 'http://www.tumblr.com', } [:authorize_path] = '/oauth/authorize' unless [:sign_in] == false super(app, :tumblr, consumer_key, consumer_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/omniauth/strategies/oauth/tumblr.rb', line 20 def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user['name'], 'user_info' => user_info, 'extra' => { 'user_hash' => user }, } ) end |
#user ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/omniauth/strategies/oauth/tumblr.rb', line 43 def user tumblelogs = user_hash['tumblr']['tumblelog'] if tumblelogs.kind_of?(Array) @user ||= tumblelogs[0] else @user ||= tumblelogs end end |
#user_hash ⇒ Object
52 53 54 55 |
# File 'lib/omniauth/strategies/oauth/tumblr.rb', line 52 def user_hash url = 'http://www.tumblr.com/api/authenticate' @user_hash ||= Hash.from_xml(@access_token.get(url).body) end |
#user_info ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/omniauth/strategies/oauth/tumblr.rb', line 32 def user_info { 'nickname' => user['name'], 'name' => user['title'], 'image' => user['avatar_url'], 'urls' => { 'website' => user['url'], } } end |