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
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/omniauth/strategies/instagram.rb', line 61 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
12 13 14 |
# File 'lib/omniauth/strategies/instagram.rb', line 12 def callback_url full_host + script_name + callback_path end |
#generate_sig(endpoint, params) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/omniauth/strategies/instagram.rb', line 72 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') return OpenSSL::HMAC.hexdigest(digest, secret, sig) end |
#raw_info ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/omniauth/strategies/instagram.rb', line 43 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
16 17 18 19 20 21 22 |
# File 'lib/omniauth/strategies/instagram.rb', line 16 def request_phase [:scope] ||= 'basic' [:response_type] ||= 'code' [:enforce_signed_requests] ||= false [:extra_data] ||= false super end |