在客户端,在 Flutter 中
[email protected]调用
fetchSignInMethodsForEmail
,它会返回一个空列表Signup failed [firebase_auth/email-already-in-use] The email address is already in use by another account.
在第3步中,为什么它返回一个空列表?我希望
['google']
?
我的目标是告诉用户
Hey, use Google Authentication with this email
,以防他们忘记。
这可能吗?
自 2023 年 9 月 15 日起,这是新 Firebase 项目默认启用的一项安全新功能。这称为电子邮件枚举保护。
您可以使用 gcloud auth print-access-token 使用 NodeJS firebase-admin 或以下命令禁用电子邮件枚举保护:
gcloud auth print-access-token --project=PROJECT_ID
使用 Identity Toolkit API 禁用电子邮件枚举保护:
curl -X PATCH -d "{'email_privacy_config':{'enable_improved_email_privacy':"false"}}" \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' -H 'X-Goog-User-Project: PROJECT_ID' \
"https://identitytoolkit.googleapis.com/admin/v2/projects/PROJECT_ID/config?updateMask=email_privacy_config"
替换以下内容:
ACCESS_TOKEN: the access token you generated earlier
PROJECT_ID: your project ID
对于 firebase-admin,请使用:
import {getAuth} from "firebase-admin/auth";
import firebase from "firebase-admin";
import serviceAccount from "./path-to-firebase-adminsdk.json" assert { type: "json" };
firebase.initializeApp({
credential: firebase.credential.cert(serviceAccount),
});
const ans = await getAuth().projectConfigManager().updateProjectConfig(
{
emailPrivacyConfig: {
enableImprovedEmailPrivacy: false,
},
}
);
console.log(ans)
有一个 2 个月前的 github 问题,有更多上下文 https://github.com/firebase/firebase-ios-sdk/issues/11810 ,与客户端无关。 https://github.com/firebase/firebase-ios-sdk/issues/11810#issuecomment-1726320394
https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection