Disable Facebook social login permanently
Facebook Login for Business (the only Login product a Business-type app gets, needed here for Page/Messenger/Instagram) has no email/public_profile permission to request, only business asset permissions - there is no config_id that can resolve a user's identity. credentials() now always returns null for facebook so the button stays hidden; Google login is unaffected. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -63,7 +63,7 @@ npm run dev # http://localhost:3000
|
||||
|
||||
### ปุ่มเข้าสู่ระบบด้วย Facebook / Google (หน้า /login)
|
||||
|
||||
- **Facebook** — แอป Meta เดียวกัน: เพิ่ม `https://<domain>/api/auth/oauth/facebook/callback` ใน Valid OAuth Redirect URIs. ขอแค่ `email` + `public_profile` (Standard Access ไม่ต้อง App Review) แต่โหมด Development คนที่ login ได้ต้องมี role ในแอป — เปิดให้ทุกคนต้องสลับแอปเป็น Live
|
||||
- **Facebook** — ปิดถาวร: แอปประเภทธุรกิจ (จำเป็นสำหรับ Page/Messenger/Instagram) ได้แค่ product "Facebook Login for Business" ซึ่งไม่มี permission `email`/`public_profile` ให้ขอเลย (มีแต่ asset permission เช่น `pages_show_list`) จึงเอาข้อมูลตัวตนผู้ใช้มา resolve ไม่ได้ — `credentials()` ใน `src/lib/auth/social.ts` return null ให้ facebook เสมอ ปุ่มเลยไม่โชว์ใน `/login`
|
||||
- **Google** — Google Cloud Console → APIs & Services → Credentials → Create OAuth client ID (Web application) → Authorized redirect URI: `https://<domain>/api/auth/oauth/google/callback` (local: `http://localhost:3000/api/auth/oauth/google/callback`) → ใส่ `GOOGLE_CLIENT_ID` / `GOOGLE_CLIENT_SECRET`. OAuth consent screen สถานะ Testing ใช้ได้เฉพาะ test users ที่เพิ่มไว้ — กด Publish app ให้ทุกคนใช้ได้ (scope `openid email profile` ไม่ต้อง verify)
|
||||
|
||||
ทางเลือก: ใส่ `META_SYSTEM_USER_TOKEN` (system user ใน Business Manager ที่ assign เพจไว้) แล้วเพจจะขึ้นในรายการเหมือนกัน
|
||||
|
||||
@@ -50,8 +50,13 @@ export interface SocialProfile {
|
||||
}
|
||||
|
||||
function credentials(provider: SocialProvider): { id: string; secret: string } | null {
|
||||
const id = provider === "google" ? process.env.GOOGLE_CLIENT_ID : process.env.META_APP_ID;
|
||||
const secret = provider === "google" ? process.env.GOOGLE_CLIENT_SECRET : process.env.META_APP_SECRET;
|
||||
// Facebook Login for Business (the only Login product available to a Business-type
|
||||
// app, which this project needs for Page/Messenger/Instagram) has no email/public_profile
|
||||
// permission to request — only business asset permissions (pages_show_list, etc).
|
||||
// There is no config_id that grants identity data, so this button stays disabled.
|
||||
if (provider === "facebook") return null;
|
||||
const id = process.env.GOOGLE_CLIENT_ID;
|
||||
const secret = process.env.GOOGLE_CLIENT_SECRET;
|
||||
return id && secret ? { id, secret } : null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user