Class: OmniAuth::Strategies::Instagram
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Instagram
show all
- Defined in:
- lib/omniauth/strategies/oauth2/instagram.rb
Overview
Authenticate to Facebook 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) ⇒ Instagram
Returns a new instance of Instagram.
13
14
15
16
17
18
19
|
# File 'lib/omniauth/strategies/oauth2/instagram.rb', line 13
def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
client_options = {
:authorize_url => 'https://api.instagram.com/oauth/authorize',
:token_url => 'https://api.instagram.com/oauth/access_token',
}
super(app, :instagram, client_id, client_secret, client_options, options, &block)
end
|
Instance Method Details
#auth_hash ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/omniauth/strategies/oauth2/instagram.rb', line 21
def auth_hash
OmniAuth::Utils.deep_merge(
super, {
'uid' => user_data['data']['id'],
'user_info' => user_info,
'extra' => {
'user_hash' => user_data['data'],
}
}
)
end
|
#callback_phase ⇒ Object
39
40
41
42
|
# File 'lib/omniauth/strategies/oauth2/instagram.rb', line 39
def callback_phase
options[:grant_type] ||= 'authorization_code'
super
end
|
#request_phase ⇒ Object
33
34
35
36
37
|
# File 'lib/omniauth/strategies/oauth2/instagram.rb', line 33
def request_phase
options[:scope] ||= 'basic'
options[:response_type] ||= 'code'
super
end
|
#user_data ⇒ Object
44
45
46
47
|
# File 'lib/omniauth/strategies/oauth2/instagram.rb', line 44
def user_data
@access_token.options.merge!({:param_name => 'access_token', :mode => :query})
@data ||= MultiJson.decode(@access_token.get('/v1/users/self'))
end
|
#user_info ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/omniauth/strategies/oauth2/instagram.rb', line 49
def user_info
{
'nickname' => user_data['data']['username'],
'name' => user_data['data']['full_name'],
'image' => user_data['data']['profile_picture'],
}
end
|