Class: OmniAuth::Strategies::Instagram
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Instagram
- Defined in:
- lib/omniauth/strategies/instagram.rb
Instance Method Summary collapse
-
#authorize_params ⇒ Object
You can pass
scope
params to the auth request, if you need to set them dynamically. - #callback_url ⇒ Object
- #generate_sig(endpoint, params) ⇒ Object
- #raw_info ⇒ Object
- #request_phase ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
You can pass scope
params to the auth request, if you need to set them dynamically. You can also set these options in the OmniAuth config :authorize_params option.
For example: /auth/instagram?scope=likes+photos
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/omniauth/strategies/instagram.rb', line 59 def super.tap do |params| %w[scope].each do |v| params[v.to_sym] = request.params[v] if request.params[v] if params[v.to_sym] params[v.to_sym] = Array(params[v.to_sym]).join(' ') end end end end |
#callback_url ⇒ Object
10 11 12 |
# File 'lib/omniauth/strategies/instagram.rb', line 10 def callback_url full_host + script_name + callback_path end |
#generate_sig(endpoint, params) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/omniauth/strategies/instagram.rb', line 70 def generate_sig(endpoint, params) require 'openssl' require 'base64' sig = endpoint secret = [:client_secret] params.sort.map do |key, val| sig += '|%s=%s' % [key, val] end digest = OpenSSL::Digest.new('sha256') OpenSSL::HMAC.hexdigest(digest, secret, sig) end |
#raw_info ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/omniauth/strategies/instagram.rb', line 41 def raw_info if [:extra_data] endpoint = '/users/self' params = {} access_token.[:mode] = :query access_token.[:param_name] = 'access_token' params['sig'] = generate_sig(endpoint, 'access_token' => access_token.token) if [:enforce_signed_requests] @data ||= access_token.get("/v1#{endpoint}", params: params).parsed['data'] || {} else @data ||= access_token.params['user'] end @data end |
#request_phase ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/omniauth/strategies/instagram.rb', line 14 def request_phase [:scope] ||= 'basic' [:response_type] ||= 'code' [:enforce_signed_requests] ||= false [:extra_data] ||= false super end |