Class: OmniAuth::Strategies::Dropbox

Inherits:
OAuth
  • Object
show all
Defined in:
lib/omniauth/strategies/oauth/dropbox.rb

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) ⇒ Dropbox

Returns a new instance of Dropbox.



7
8
9
10
11
12
13
14
15
16
# File 'lib/omniauth/strategies/oauth/dropbox.rb', line 7

def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
  client_options = {
    :authorize_url => 'https://www.dropbox.com/0/oauth/authorize',
    :access_token_url => 'https://api.dropbox.com/0/oauth/access_token',
    :proxy => ENV['HTTP_PROXY'] || ENV['http_proxy'],
    :request_token_url => 'https://api.dropbox.com/0/oauth/request_token',
    :site => 'https://api.dropbox.com',
  }
  super(app, :dropbox, consumer_key, consumer_secret, client_options, options, &block)
end

Instance Method Details

#auth_hashObject



18
19
20
21
22
23
24
25
# File 'lib/omniauth/strategies/oauth/dropbox.rb', line 18

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

#user_dataObject



27
28
29
# File 'lib/omniauth/strategies/oauth/dropbox.rb', line 27

def user_data
  @data ||= MultiJson.decode(@access_token.get('/0/account/info').body)
end

#user_infoObject



31
32
33
34
35
36
37
# File 'lib/omniauth/strategies/oauth/dropbox.rb', line 31

def 
  {
    'name' => user_data['display_name'],
    'uid' => user_data['uid'],
    'email' => user_data['email']
  }
end