Class: OmniAuth::Strategies::Dopplr

Inherits:
OAuth
  • Object
show all
Defined in:
lib/omniauth/strategies/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

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.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :client_options (Hash, {})

    Options to be passed directly to the OAuth Consumer



17
18
19
20
21
22
23
24
25
26
# File 'lib/omniauth/strategies/dopplr.rb', line 17

def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
  client_options = {
    :site => 'https://www.dopplr.com',
    :request_token_path => "/oauth/request_token",
    :access_token_path  => "/oauth/access_token",
    :authorize_path    => "/oauth/authorize"
  }
  
  super(app, :dopplr, consumer_key, consumer_secret, client_options, options, &block)
end

Instance Method Details

#auth_hashObject



45
46
47
48
49
50
# File 'lib/omniauth/strategies/dopplr.rb', line 45

def auth_hash
  OmniAuth::Utils.deep_merge(super, {
    'uid' => user_data['nick'],
    'user_info' => 
  })
end

#user_dataObject



28
29
30
# File 'lib/omniauth/strategies/dopplr.rb', line 28

def user_data
  @data ||= MultiJson.decode(@access_token.get('/oauthapi/whoami').body)['whoami']
end

#user_infoObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/omniauth/strategies/dopplr.rb', line 32

def 
  {
    '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