我正在 Firebase (web js sdk) 中设置 Microsoft 身份验证,但我遇到了 firebase.auth.signInWithCredential
错误。我可以从 Microsoft 成功获取 ID token ,但 Firebase 身份验证步骤失败。我已经尝试过 Firebase v8 和 v9,以及各种形成我的凭据对象的方法。事实上,即使传递访问 token ,我也会遇到同样的错误。 Firebase 库似乎有问题。
有没有人遇到过这个问题并解决了它?
代码:
const { id_token } = authResponse.params; // I've verified that id_token is correct
const credential = new firebase.auth.OAuthProvider("microsoft.com").credential({
idToken: id_token,
rawNonce: "12345",
});
await firebase.auth().signInWithCredential(credential);
凭据似乎生成良好:
Object {
"accessToken": undefined,
"idToken": "eyJ0eXAiOiJKV...",
"nonce": "12345",
"pendingToken": null,
"providerId": "microsoft.com",
"secret": undefined,
"signInMethod": "microsoft.com",
}
但是 signInWithCredential
步骤出现以下错误:
Uncaught (in promise)
code: "auth/internal-error"
message: "Invalid IdP response/credential: http://localhost?id_token=eyJ0eXAiOiJKV..."
最佳答案
Microsoft OAuth 似乎不支持 signInWithCredential
。 https://cloud.google.com/identity-platform/docs/web/microsoft
我将尝试为现有用户执行 signInWithCustomToken
并警告新用户首先在网络上注册,我将在网站上执行 signInWithPopup
关于javascript - Firebase Microsoft SignInWithCredential,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70268222/