Class: InstagramConnect::OauthController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- InstagramConnect::OauthController
- Defined in:
- app/controllers/instagram_connect/oauth_controller.rb
Overview
Drives the "Connect Instagram" OAuth flow: redirect to Meta's login dialog, then exchange the returned code for a stored Account.
Instance Method Summary collapse
Instance Method Details
#callback ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/instagram_connect/oauth_controller.rb', line 12 def callback return redirect_with("Instagram authorization was declined: #{params[:error]}") if params[:error].present? return redirect_with("OAuth state mismatch — please try connecting again.") if invalid_state? Connect.call(code: params[:code], redirect_uri: callback_url, connected_by_id: instagram_connect_user_id) session.delete(:instagram_connect_oauth_state) redirect_to after_connect_path, notice: "Instagram account connected." rescue InstagramConnect::Error => e redirect_with("Could not connect Instagram: #{e.}") end |
#start ⇒ Object
5 6 7 8 9 10 |
# File 'app/controllers/instagram_connect/oauth_controller.rb', line 5 def start state = SecureRandom.urlsafe_base64(16) session[:instagram_connect_oauth_state] = state url = Auth.for(InstagramConnect.configuration).(redirect_uri: callback_url, state: state) redirect_to url, allow_other_host: true end |