How do I structure my DB to set up oAuth integrations with Facebook, Instagram, etc.
I have a Shopify app where they (Shopify) handle authentication. If you can login to your Shop on their platform, you can login to the Rails app. Therefore I have no need for Devise. It seems like every tutorial or video focuses on adding oauth in tandem with Devise. Curious how I could best structure allowing Shops to connect their Facebook & Instagram to my rails app. It wouldn't be to log them in but rather to make API requests on their behalf for things like sending Messages
Hey Drew,
You'd just create a model like ConnectedAccount to store the details and associate them with your Shop model.
Monday's screencast actually walks through this a bit using OmniAuth params. You can pass the Shop's SGID to OmniAuth and then look it up in the callback controller.
<%= link_to "Connect Facebook", authorize_facebook_path(shop: @shop.to_sgid(for: :connecting)) %>
Then your controller will look that up:
class OmniauthCallbacksController < ApplicationController
def create
sgid = request.env['omniauth.params'].fetch("shop")
shop = GlobalID::Locator.locate_signed(sgid, for: 'sharing')
shop.connected_accounts.create!(
# omniauth.auth details go here
)
redirect_to @shop, notice: "Connected!"
end
end