firebase idtoken 中缺少 Givenname 和 Familyname 声明

Givenname and Familyname claims are missing in firebase idtoken

我正在尝试使用 Firebase 为我们的 Web 应用程序实施 google 登录。 这是我为获取 idtoken 所做的工作:

  const google_provider = new GoogleAuthProvider();
  google_provider.addScope("openid");
  google_provider.addScope("profile");
  google_provider.addScope("email");
  signInWithPopup(auth, google_provider).then((result) =>
    result.user.getIdToken());

虽然我已经添加了配置文件范围,但我仍然无法在 idtokenemailpicturename 可用)

(我试过直接使用 Google 登录,在那里我可以看到所有的个人资料声明)

我错过了什么?我是不是做错了什么?

getIdToken() doesn't contain user's Google account information that you are looking for (expect name, profile image, etc). You should use the access code retrieved from sign in result to make request to Google API 返回的 Firebase ID 令牌以获取它。

signInWithPopup(auth, provider)
  .then(async (result) => {
    // This gives you a Google Access Token. You can use it to access the Google API.
    const credential = GoogleAuthProvider.credentialFromResult(result);
    const token = credential.accessToken;

    const response = await fetch('https://www.googleapis.com/oauth2/v1/userinfo', {
      headers: {
        Authorization: `Bearer ${token}`
      }
    })

    const data = await response.json();
    console.log(data);
  })