Class: OmniAuth::Strategies::Dopplr

Inherits:
OAuth
  • Object
show all
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

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



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, options={}, &block)
  client_options = {
    :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, client_options, options, &block)
end

Instance Method Details

#auth_hashObject



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' => ,
    }
  )
end

#user_dataObject



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_infoObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/omniauth/strategies/oauth/dopplr.rb', line 37

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