To allow LogicSpike users to connect their Instagram and Facebook accounts, we need to create our "Master App" on the Facebook Developer portal. Follow these exact steps to get your FACEBOOK_CLIENT_ID and FACEBOOK_CLIENT_SECRET.
Step 1: Create the Facebook App
- Go to the Facebook Developers Portal.
- Log in with your Facebook account.
- In the top right corner, click My Apps.
- Click the green Create App button.
- What do you want your app to do?: Select Business and click Next.
- Add an app name: Type
LogicSpike Content Engine. - App contact email: Provide your email address.
- Business Account: Select your Business Manager account (or leave as "No Business Manager selected" if you don't have one).
- Click Create app and enter your Facebook password if prompted.
Step 2: Add Necessary Products
You are now on the App Dashboard. We need to add products for login and Instagram.
- Scroll down to the Add products to your app section.
- Find Facebook Login for Business and click Set up.
- On the left sidebar, under "Use cases", ensure Authentication and account creation is configured.
Step 3: Configure the OAuth Redirect URL (Crucial Step)
Facebook needs to know that http://localhost:3000 is a safe place to send the secret code back to.
- In the left sidebar, click Facebook Login for Business > Settings.
- Look for the field called Valid OAuth Redirect URIs.
- Paste exactly this URL into the box:
http://localhost:3000/dashboard/settings - Make sure:
- Client OAuth Login is Yes
- Web OAuth Login is Yes
- Enforce HTTPS is Yes (Facebook forces HTTPS but usually makes exceptions for
localhost).
- Click Save Changes at the bottom right.
Step 4: Add Necessary Permissions (Scopes)
We need permission to post content on behalf of the user. Facebook requires you to request these permissions in the app settings, but we will also ask for them in our code.
- On the left sidebar, click App Review > Permissions and Features.
- Search for and Request advanced access for the following permissions (this may require business verification or app review if you want to take it out of Development mode later, but is fine for local testing):
pages_show_listpages_read_engagementpages_manage_postsinstagram_basicinstagram_content_publish
Step 5: Get Your Keys
- In the left sidebar, go to App Settings > Basic.
- Look at the top. You will see two fields:
- App ID: (This is a long number)
- App Secret: (Click 'Show' and enter your Facebook password to reveal it).
Step 6: Update Environment Variables
- Copy the App ID.
- Open your
apps/content-engine/.dev.varsfile. - Paste the App ID into the
FACEBOOK_CLIENT_IDvariable. - Copy the App Secret.
- Paste the App Secret into the
FACEBOOK_CLIENT_SECRETvariable.
It should look something like this:
FACEBOOK_CLIENT_ID="1234567890123456"
FACEBOOK_CLIENT_SECRET="abc123def456ghi789jkl012mno345pqr"Step 7: Restart and Test
- Go to your terminal running
turbo run dev. - Press
Ctrl + C(orCmd + C) to stop it. - Run
npm run devorturbo run devagain to load the new.dev.vars. - Go to
http://localhost:3000/dashboard/settingsand click the "Connect Instagram" button!