From e632fa7139eff767f1d4d0d44a95f605db2b68d2 Mon Sep 17 00:00:00 2001 From: chenhang Date: Tue, 16 Jun 2026 19:22:14 +0800 Subject: [PATCH] fix(auth): correct Facebook Graph field expansion syntax for picture Facebook Graph API field expansion uses parentheses, not equals signs. The buggy `picture.type=large` produced HTTP 400 with `OAuthException code 2500: Syntax error ... at character 32`. Fix `FIELDS` constant and 2 JSDoc comment lines in facebook-graph.ts to use `picture.type(large)` per Facebook's documented syntax. Effect: after Facebook OAuth sync, `fetchFacebookUserData` now succeeds (HTTP 200), `UserStorage.setAvatarUrl` and `AuthStorage.setFacebookId` get populated, and the `[auth-machine] syncFacebookBackendActor: fetchFacebookUserData failed (continuing anyway)` warning stops firing on the happy path. --- src/utils/facebook-graph.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/facebook-graph.ts b/src/utils/facebook-graph.ts index e8980a4f..fd2bbd06 100644 --- a/src/utils/facebook-graph.ts +++ b/src/utils/facebook-graph.ts @@ -14,8 +14,8 @@ * 不引入 Facebook SDK(window.FB)—— 减少前端 bundle 体积,Graph API * 单次 HTTP 调用即可拿到所有字段。SDK 加载慢、还要管 init。 * - * 端点:`https://graph.facebook.com/me?fields=id,name,email,picture.type=large&access_token=...` - * - `picture.type=large` 返回 ~200px 头像 URL(默认 square 50px 太小) + * 端点:`https://graph.facebook.com/me?fields=id,name,email,picture.type(large)&access_token=...` + * - `picture.type(large)` 返回 ~200px 头像 URL(默认 square 50px 太小) * - 不指定 version 走最新稳定版 * - 不需要 appId / appSecret(accessToken 自身就是凭证) */ @@ -31,9 +31,9 @@ const GRAPH_ME_URL = "https://graph.facebook.com/me"; /** * 拉取字段集合: * - id / name / email —— 给本地 FacebookUserData DTO - * - picture.type=large —— 头像 URL(默认 square 50px 太小) + * - picture.type(large) —— 头像 URL(默认 square 50px 太小) */ -const FIELDS = "id,name,email,picture.type=large"; +const FIELDS = "id,name,email,picture.type(large)"; /** * 用 accessToken 调 Facebook Graph `/me` 拉用户资料。