Class: OmniAuth::Strategies::Gowalla
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Gowalla
show all
- Defined in:
- lib/omniauth/strategies/oauth2/gowalla.rb
Overview
Authenticate to Gowalla utilizing OAuth 2.0 and retrieve
basic user information.
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) ⇒ Gowalla
Returns a new instance of Gowalla.
16
17
18
19
20
21
22
|
# File 'lib/omniauth/strategies/oauth2/gowalla.rb', line 16
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
client_options = {
:authorize_url => 'https://gowalla.com/api/oauth/new',
:token_url => 'https://api.gowalla.com/api/oauth/token',
}
super(app, :gowalla, client_id, client_secret, client_options, options, &block)
end
|
Instance Method Details
#auth_hash ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/omniauth/strategies/oauth2/gowalla.rb', line 24
def auth_hash
OmniAuth::Utils.deep_merge(
super, {
'uid' => user_data['url'].split('/').last,
'user_info' => user_info,
'extra' => {
'user_hash' => user_data,
'refresh_token' => refresh_token,
'token_expires_at' => token_expires_at,
},
}
)
end
|
#refresh_token ⇒ Object
42
43
44
|
# File 'lib/omniauth/strategies/oauth2/gowalla.rb', line 42
def refresh_token
@refresh_token ||= @access_token.refresh_token
end
|
#request_phase ⇒ Object
50
51
52
53
|
# File 'lib/omniauth/strategies/oauth2/gowalla.rb', line 50
def request_phase
options[:scope] ||= 'read'
super
end
|
#token_expires_at ⇒ Object
46
47
48
|
# File 'lib/omniauth/strategies/oauth2/gowalla.rb', line 46
def token_expires_at
@expires_at ||= @access_token.expires_at
end
|
#user_data ⇒ Object
38
39
40
|
# File 'lib/omniauth/strategies/oauth2/gowalla.rb', line 38
def user_data
@data ||= MultiJson.decode(@access_token.get('/users/me.json'))
end
|
#user_info ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/omniauth/strategies/oauth2/gowalla.rb', line 55
def user_info
{
'name' => "#{user_data['first_name']} #{user_data['last_name']}",
'nickname' => user_data['username'],
'first_name' => user_data['first_name'],
'last_name' => user_data['last_name'],
'location' => user_data['hometown'],
'description' => user_data['bio'],
'image' => user_data['image_url'],
'urls' => {
'Gowalla' => "http://www.gowalla.com#{user_data['url']}",
'Website' => user_data['website'],
},
}
end
|