Your Facebook integration is failing NOT because of roles, but because of a missing business_management permission.
Facebook made an undocumented breaking change in 2023: Pages owned through Business Manager now require the business_management permission to appear in /me/accounts API responses.
Your situation:
- ✅ You ARE Admin on Facebook Page (CodeStorm Hub - 345870211942784)
- ✅ You ARE Admin on Facebook App (897721499580400)
- ❌ But your Page is likely managed through Business Manager
- ❌ Without
business_managementpermission, API returns empty array
Source: Facebook Non-Versioned Changes 2023
The business_management scope has been added to your OAuth flow:
// src/app/api/facebook/auth/initiate/route.ts (Line 43)
'business_management', // ⚠️ CRITICAL: Required for Business Manager pagesTwo new endpoints to diagnose and verify the fix:
GET /api/facebook/debug/token?integrationId=xxx- Check token permissionsGET /api/facebook/debug/fetch-pages?integrationId=xxx&pageId=345870211942784- Test alternative methods
Since the code is already updated, you just need to re-authenticate to grant the new permission:
npm run dev- Go to:
http://localhost:3000/dashboard/integrations - Click "Connect Facebook" (or "Reconnect" if exists)
- Facebook will show OAuth prompt
- IMPORTANT: Look for prompt asking about Business Manager access
- Click "Allow" or "Continue" to grant permission
- Complete OAuth flow
After OAuth completes, check dev server console logs:
[Facebook Callback] Pages API Response: {
"dataLength": 1, // ✅ Should be 1 or more now!
"firstPage": {
"id": "345870211942784",
"name": "CodeStorm Hub"
}
}
# Replace clx... with your actual integration ID
curl "http://localhost:3000/api/facebook/debug/token?integrationId=clx..."Expected Result (Current broken state):
{
"permissions": {
"hasBusinessManagement": false, // ❌ Missing
"missing": ["business_management"]
},
"diagnosis": {
"canAccessPages": false,
"recommendation": "CRITICAL: Missing business_management permission..."
}
}Follow "Step 2" above to grant new permission
# Use new integration ID from re-auth
curl "http://localhost:3000/api/facebook/debug/token?integrationId=NEW_ID"Expected Result (Fixed):
{
"permissions": {
"hasBusinessManagement": true, // ✅ Fixed!
"hasAllRequired": true,
"missing": []
},
"diagnosis": {
"canAccessPages": true,
"recommendation": "All required permissions granted. Token is valid."
}
}curl "http://localhost:3000/api/facebook/debug/fetch-pages?integrationId=NEW_ID&pageId=345870211942784"Expected Result:
{
"summary": {
"anyMethodSucceeded": true,
"recommendation": "Success! /me/accounts is working correctly."
},
"methods": {
"method1_me_accounts": {
"success": true, // ✅ Now works!
"pagesCount": 1,
"pages": [
{
"id": "345870211942784",
"name": "CodeStorm Hub"
}
]
}
}
}OAuth Scopes Requested:
- email ✅
- public_profile ✅
- pages_show_list ✅
- pages_manage_metadata ✅
- pages_read_engagement ✅
- business_management ❌ MISSING
Result: CodeStorm Hub Page is in Business Manager
→ Without business_management, /me/accounts excludes it
→ API returns empty array []
OAuth Scopes Requested:
- email ✅
- public_profile ✅
- pages_show_list ✅
- pages_manage_metadata ✅
- pages_read_engagement ✅
- business_management ✅ NOW INCLUDED
Result: CodeStorm Hub Page is in Business Manager
→ With business_management, /me/accounts includes it
→ API returns CodeStorm Hub ✅
Test manually in Facebook's official tool:
- Go to: https://developers.facebook.com/tools/explorer/
- Select your app: StormCom (ID: 897721499580400)
- Click "Get User Access Token"
- CRITICAL: Check these permissions:
- ✅ public_profile
- ✅ pages_show_list
- ✅ business_management ← MUST CHECK THIS
- Click "Generate Access Token"
- Facebook prompts for Business Manager access → Click "Allow"
- In the query field, enter:
me/accounts?fields=id,name - Click "Submit"
- Result: Should now show CodeStorm Hub ✅
When you click "Connect Facebook" after the code update, Facebook will show:
Previous OAuth (before fix):
StormCom wants to:
✅ Access your email
✅ Access your public profile
✅ Manage your Pages
Updated OAuth (after fix):
StormCom wants to:
✅ Access your email
✅ Access your public profile
✅ Manage your Pages
✅ Access your Business Manager ← NEW PROMPT
Click "Allow" or "Continue" when you see the Business Manager prompt.
Check 1: Verify permission was granted
curl "http://localhost:3000/api/facebook/debug/token?integrationId=NEW_ID"Look for: "hasBusinessManagement": true
Check 2: Verify Page ownership
- Go to: https://business.facebook.com/
- Check if CodeStorm Hub Page is listed under your Business Manager
- Verify you have Admin role on the Page
Check 3: Token expiration
- OAuth tokens are long-lived (60 days) but can expire
- Try re-authenticating again
Check 4: Facebook cache
- Sometimes Facebook caches permissions
- Wait 5 minutes and try again
- Or revoke app access and re-authorize:
- Go to: https://www.facebook.com/settings?tab=applications
- Find "StormCom" → Remove
- Re-authenticate from your app
This means either:
- Your Page is NOT in Business Manager (rare) - use manual Page ID entry
- You already granted
business_managementin a previous session - The scope wasn't properly added - verify
initiate/route.tsline 43
| File | Change | Line |
|---|---|---|
src/app/api/facebook/auth/initiate/route.ts |
Added business_management scope |
43 |
src/app/api/facebook/debug/token/route.ts |
NEW debug endpoint | - |
src/app/api/facebook/debug/fetch-pages/route.ts |
NEW test endpoint | - |
- ✅ Code is ready -
business_managementscope added - ⏳ Your action: Re-authenticate via OAuth flow
- ⏳ Verify: Use debug endpoints to confirm fix
- ⏳ Test: Complete integration should work
This was a non-versioned breaking change in 2023, meaning:
- ❌ Not announced in standard changelog
- ❌ Affects ALL API versions (v13.0 to v21.0)
- ❌ No migration guide provided
- ✅ Only documented in "Non-Versioned Changes" page
Many developers hit this same issue in 2023-2024. It's not your fault!
If issues persist after re-authentication:
- Share debug endpoint output
- Check Facebook App Dashboard for any warnings
- Verify Page is in Business Manager
- Try manual Page ID entry as fallback (already implemented)
Status: ✅ Code ready, pending user re-authentication
Expected Time: 2-3 minutes to re-auth
Success Rate: Very high (based on research)