Skip to content

Comments

Marcus finishes facebook autoposter frontend#4714

Open
marcusyi1 wants to merge 16 commits intodevelopmentfrom
Marcus-finishes-facebook-autoposter-fe
Open

Marcus finishes facebook autoposter frontend#4714
marcusyi1 wants to merge 16 commits intodevelopmentfrom
Marcus-finishes-facebook-autoposter-fe

Conversation

@marcusyi1
Copy link
Contributor

@marcusyi1 marcusyi1 commented Jan 15, 2026

Description

This PR implements a comprehensive Facebook Pages auto-poster system for HGN, building upon and modernizing the foundational work completed in PR3270/PR1268 (basic posting) and PR3466/PR1359 (scheduling framework) by Snehal Patare.

Key capabilities:

  • OAuth Authentication Flow: Secure Facebook Page connection via Facebook Login, with automatic token storage and validation
  • Direct Posting: Post text, links, and images (URL or file upload) to connected Facebook Pages
  • Post Scheduling: Schedule posts with PST timezone support, managed by cron jobs running every minute
  • Post History & Management: Track all posts (direct and scheduled) with status monitoring, filtering, and edit/cancel capabilities for pending posts
  • Image Upload Support: Direct file uploads (JPEG/PNG/GIF/WebP, <10MB) using Facebook's native multipart form-data API

This implementation uses modern OAuth patterns instead of hardcoded tokens, provides comprehensive error handling with user-friendly messaging, and includes permission-based access control using HGN's existing requestor system.

Fixes: High Priority Task - "Create appropriate auto-poster for Facebook + Facebook Groups" (Jae) - Facebook Pages component

Related PRs (if any):

Builds upon (already merged or pending approval):

  • Frontend PR3270 & Backend PR1268 - Basic Facebook posting foundation (Snehal)
  • Frontend PR3466 & Backend PR1359 - Scheduling framework (Snehal)

Do git checkout of https://github.com/OneCommunityGlobal/HGNRest/pull/2005/ in order to test this PR

Main changes explained:

New Files:

  • src/actions/facebookAuthActions.js
  • src/components/Announcements/FacebookSettings.jsx

Updated Files:

  • src/components/Announcements/index.jsx
  • src/components/Announcements/SocialMediaPostDetails.jsx
  • src/components/Announcements/FacebookHistory.jsx
  • src/actions/sendSocialMediaPosts.js
  • src/utils/URL.js
  • src/components/Announcements/Announcements.css

Environment Variables Added:

  • REACT_APP_FACEBOOK_APP_ID - Your Facebook App ID (must match backend FACEBOOK_APP_ID)

How to test:

Prerequisites

Step 1: Create a Facebook Developer Account

  1. Go to [developers.facebook.com](https://developers.facebook.com)
  2. Click Get Started or Log In with your Facebook account
  3. Complete the registration if prompted

Step 2: Create a New App

⚠️ Important: Do NOT select "Facebook Login for Business" or try to make your app Live. This will trigger verification requirements that are unnecessary for testing.

  1. Click My Apps (top right) → Create App
  2. Use case: Select "Other" → Click Next
  3. App type: Select "Consumer" → Click Next
  4. App details:
    • App name: HGN Facebook Test - [YourName]
    • Contact email: Your email
    • Business portfolio: Skip/None
  5. Click Create App

Step 3: Add Facebook Login Product

  1. From your app's dashboard, scroll to "Add products to your app"
  2. Find "Facebook Login" (the standard one, NOT "Facebook Login for Business")
  3. Click Set Up → Select Web
  4. Enter https://localhost:3000 as the Site URL → Click SaveContinue
  5. Skip the remaining quickstart steps

Step 4: Configure OAuth Settings

  1. In the left sidebar, go to Facebook Login → Settings
  2. Configure:
Setting Value
Client OAuth Login Yes
Web OAuth Login Yes
Enforce HTTPS Yes
Valid OAuth Redirect URIs https://localhost:3000
  1. Under "Allowed Domains for the JavaScript SDK" add: localhost
  2. Click Save Changes

Step 5: Get Your App Credentials

  1. Go to App Settings → Basic
  2. Copy your App ID and App Secret (click Show)

Step 6: Configure Environment Variables

Frontend (.env):

REACT_APP_FACEBOOK_APP_ID=your_app_id_here

Backend (.env):

FACEBOOK_APP_ID=your_app_id_here
FACEBOOK_APP_SECRET=your_app_secret_here
FACEBOOK_GRAPH_URL=https://graph.facebook.com/v19.0

Step 7: Enable HTTPS for Local Development

Facebook OAuth requires HTTPS. If using Vite:

  1. Install: npm install -D @vitejs/plugin-basic-ssl
  2. Update vite.config.js:
import basicSsl from '@vitejs/plugin-basic-ssl';

export default defineConfig({
  plugins: [react(), basicSsl()],
  // ... rest of config
});

Step 8: Run and Test

  1. Check out this branch
  2. Run npm install and npm run start:local
  3. Clear site data/cache
  4. Log in as a user with send email permissions (Owner or Administrator)
  5. Navigate to Dashboard → Other Links → Send Email → Facebook

Verification Checklist

  • OAuth Authentication Flow - Connect a Facebook Page
  • Direct Posting – Text Only
  • Direct Posting – With Link
  • Direct Posting – Image URL
  • Direct Posting – File Upload (JPEG/PNG/GIF/WebP)
  • Invalid File Type Rejection
  • Scheduling Posts – Future Post
  • Scheduling – Image File Upload
  • Edit Scheduled Post
  • Cancel Scheduled Post
  • Post History – View and Filtering
  • Disconnect and Reconnect Flow
  • Permissions & Authorization (non-admin users cannot connect/disconnect)
  • [Dark mode](https://docs.google.com/document/d/11OXJfBBedK6vV-XvqWR8A9lOH0BsfnaHx01h1NZZXfI) compatibility

Troubleshooting

"Facebook Login for Business requires advanced access"

You selected the wrong product. Remove "Facebook Login for Business" and add regular "Facebook Login" instead.

"App must be Live to use this feature"

Stay in Development Mode. You don't need to make the app Live for testing. The app creator can test all features in dev mode.

"No Facebook Pages found"

Make sure you have admin access to at least one Facebook Page. Create a test page at [facebook.com/pages/create](https://www.facebook.com/pages/create).

OAuth popup blocked

Allow popups for localhost in your browser settings.

"Invalid redirect URI"

Ensure https://localhost:3000 is listed in Facebook Login → Settings → Valid OAuth Redirect URIs.

Graph API Error Code 10 (Post History)

This occurs when reading posts from Facebook's API in development mode. This is expected - posting still works, but reading the feed is restricted. Post history will show posts from MongoDB successfully; the Facebook API source may show an error.

Screenshots or videos of changes:

image image image image

@netlify
Copy link

netlify bot commented Jan 15, 2026

Deploy Preview for highestgoodnetwork-dev ready!

Name Link
🔨 Latest commit 669ef9f
🔍 Latest deploy log https://app.netlify.com/projects/highestgoodnetwork-dev/deploys/6987afdd34a2ca00086546e5
😎 Deploy Preview https://deploy-preview-4714--highestgoodnetwork-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@one-community one-community added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Jan 15, 2026
Copy link

@Anusha-Gali Anusha-Gali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Marcus,

I tried to review your PR but am unable to do so since i could not figure out few things required for the setup. If you could provide a video of setup it would be helpful.

Coming to where i am stuck, i did create a developer login and an app and did select the "Facebook login for business" but it says the below:
Facebook Login for Business requires advanced access
Your app has standard access to public_profile. To use Facebook Login for Business, switch public_profile to advanced access.

Now i did try to get advance access but it says "Verification required" and i am unable to understand what exactly am i to fill in that page, even upon adding details i could think of and saving, no luck. Also i then tried to make the app live but it stops saying i should provide a privacy policy but i am not confident as to what it is i am supposed to enter.

@marcusyi1 marcusyi1 requested a review from Anusha-Gali January 24, 2026 23:51
@maithili20
Copy link

maithili20 commented Jan 29, 2026

Hi @marcusyi1
I am reviewing your PR, and I am unable to connect to facebook. I followed entire process as mentioned in PR. I am getting error messages as seen in the screenshot below.
image
image

Copy link

@Anusha-Gali Anusha-Gali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Marcus,

I tried to review and setup following the steps you mentioned and have tried to do a facebook post. bUt i am unable to view it anywhere. Below are the screenshots showing my console log, and graph link: https://graph.facebook.com/v19.0/944703262049095/feed , and the history as well as setting at my end. Let me know if i am going wrong anywhere.

Image Image Image Image Image

@maithili20
Copy link

Hi @marcusyi1
I tested the PR—thanks a lot for helping with the setup, and kudos for getting so many pieces working. Overall, it looks good, but I noticed a few issues:

Once I disconnnect I am not able to re-connect. I get the below error.
image

Do you think history shown should be particular to me ?
image

Even though I am connected, I see facebook not connected message on top
image

The scheduled post did not work. This may be because the I disconnected the app before. But cannot test again since app is not reconnecting.
image

Also, could we remove the following statement from the PR description?(Step2) - ⚠️ Important: Do NOT select "Facebook Login for Business" or try to make your app Live. This will trigger verification requirements that are unnecessary for testing.

@@ -1,55 +1,494 @@
import React, { useState } from 'react';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React is imported twice with overlapping bindings (React/useState) which would cause a compile error.


const tabOrder = [
{ id: 'composer', label: '📝 Make Post' },
{ id: 'scheduled', label: '⏰ Scheduled Post' },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate ids will cause weird ui and state bugs

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 7, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants