forked from omniauth/omniauth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dropbox.rb
40 lines (36 loc) · 1.15 KB
/
dropbox.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'omniauth/oauth'
require 'multi_json'
module OmniAuth
module Strategies
class Dropbox < OmniAuth::Strategies::OAuth
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
def auth_hash
OmniAuth::Utils.deep_merge(
super, {
'uid' => user_data['uid'],
'user_info' => user_info,
}
)
end
def user_data
@data ||= MultiJson.decode(@access_token.get('/0/account/info').body)
end
def user_info
{
'name' => user_data['display_name'],
'uid' => user_data['uid'],
'email' => user_data['email']
}
end
end
end
end