Class: OmniAuth::Strategies::Teambox
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Teambox
show all
- Defined in:
- lib/omniauth/strategies/oauth2/teambox.rb
Instance Attribute Summary
Attributes inherited from OAuth2
#client_id, #client_options, #client_secret, #options
Instance Method Summary
collapse
Methods inherited from OAuth2
#callback_url, #client
Constructor Details
#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ Teambox
Returns a new instance of Teambox.
7
8
9
10
11
12
13
|
# File 'lib/omniauth/strategies/oauth2/teambox.rb', line 7
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
client_options = {
:authorize_url => 'https://teambox.com/oauth/authorize',
:token_url => 'https://teambox.com/oauth/token',
}
super(app, :teambox, client_id, client_secret, client_options, options, &block)
end
|
Instance Method Details
#auth_hash ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/omniauth/strategies/oauth2/teambox.rb', line 15
def auth_hash
OmniAuth::Utils.deep_merge(
super, {
'uid' => user_data['id'],
'user_info' => user_info,
'extra' => {
'user_hash' => user_data
},
}
)
end
|
#callback_phase ⇒ Object
33
34
35
36
|
# File 'lib/omniauth/strategies/oauth2/teambox.rb', line 33
def callback_phase
options[:grant_type] ||= 'authorization_code'
super
end
|
#request_phase ⇒ Object
27
28
29
30
31
|
# File 'lib/omniauth/strategies/oauth2/teambox.rb', line 27
def request_phase
options[:scope] ||= 'offline_access'
options[:response_type] ||= 'code'
super
end
|
#user_data ⇒ Object
38
39
40
|
# File 'lib/omniauth/strategies/oauth2/teambox.rb', line 38
def user_data
@data ||= MultiJson.decode(@access_token.get('/api/1/account'))
end
|
#user_info ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/omniauth/strategies/oauth2/teambox.rb', line 42
def user_info
{
'nickname' => user_data['username'],
'name' => user_data['first_name'],
'image' => user_data['avatar_url'],
}
end
|