Class: OmniAuth::Strategies::Plurk
- Defined in:
- lib/omniauth/strategies/oauth/plurk.rb
Overview
Authenticate to Plurk via OAuth and retrieve basic user info.
Please note that this strategy relies on Plurk API 2.0, which is still in Beta.
Usage: use OmniAuth::Strategies::Plurk
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) ⇒ Plurk
constructor
A new instance of Plurk.
- #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) ⇒ Plurk
Returns a new instance of Plurk.
17 18 19 20 21 22 23 24 25 |
# File 'lib/omniauth/strategies/oauth/plurk.rb', line 17 def initialize(app, consumer_key=nil, consumer_secret=nil, ={}, &block) = { :access_token_path => '/OAuth/access_token', :authorize_path => '/OAuth/authorize', :request_token_path => '/OAuth/request_token', :site => 'http://www.plurk.com', } super(app, :plurk, consumer_key, consumer_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/omniauth/strategies/oauth/plurk.rb', line 27 def auth_hash user = self.user_hash OmniAuth::Utils.deep_merge(super, { 'uid' => user['id'], 'user_info' => user_info, 'extra' => { 'user_hash' => user_hash, }, } ) end |
#user_hash ⇒ Object
51 52 53 |
# File 'lib/omniauth/strategies/oauth/plurk.rb', line 51 def user_hash @user_hash ||= MultiJson.decode(@access_token.get('/APP/Profile/getOwnProfile').body)['user_info'] end |
#user_info ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/omniauth/strategies/oauth/plurk.rb', line 40 def user_info user = self.user_hash { 'name' => user['full_name'], 'nickname' => user['display_name'] || user['nick_name'], 'location' => user['location'], 'image' => user['has_profile_image'] == 1 ? "http://avatars.plurk.com/#{user['id']}-medium#{user['avatar']}.gif" : 'http://www.plurk.com/static/default_medium.gif', 'urls' => {'Plurk' => 'http://plurk.com/' + user['nick_name']}, } end |