Class: OmniAuth::Strategies::Dopplr
- Defined in:
- lib/omniauth/strategies/oauth/dopplr.rb
Overview
Authenticate to Dopplr via OAuth and retrieve an access token for API usage
Usage: use OmniAuth::Strategies::Dopplr, '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) ⇒ Dopplr
constructor
Initialize the Dopplr strategy.
- #user_data ⇒ 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) ⇒ Dopplr
Initialize the Dopplr strategy.
14 15 16 17 18 19 20 21 22 |
# File 'lib/omniauth/strategies/oauth/dopplr.rb', line 14 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 => 'https://www.dopplr.com', } super(app, :dopplr, consumer_key, consumer_secret, , , &block) end |
Instance Method Details
#auth_hash ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/omniauth/strategies/oauth/dopplr.rb', line 28 def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_data['nick'], 'user_info' => user_info, } ) end |
#user_data ⇒ Object
24 25 26 |
# File 'lib/omniauth/strategies/oauth/dopplr.rb', line 24 def user_data @data ||= MultiJson.decode(@access_token.get('/oauthapi/whoami').body)['whoami'] end |
#user_info ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/omniauth/strategies/oauth/dopplr.rb', line 37 def user_info { 'nickname' => user_data['nick'], 'first_name' => user_data['forename'], 'last_name' => user_data['surname'], 'name' => "#{user_data['forename']} #{user_data['surname']}", 'urls' => { 'Dopplr' => user_data['dopplr_url'], 'DopplrMobile' => user_data['mobile_url'], }, } end |