来自 Microsoft Azure 的 Firebase signInWithCredentials

Eri*_*ric 7 oauth firebase firebase-authentication

通常,我会使用firebase.auth.OAuthProvider('microsoft.com')并将其传递给firebase.auth().signInWithPopup()但在我的情况下,我需要首先使用他们的库登录 Microsoft并将凭据传递回 firebase。(为什么?因为我需要他们的accessToken/refreshToken处理而不是由 firebase 完成的)。

无论如何,我似乎无法找到一种方法来获取微软提供的凭据并将它们成功传递回 firebase ......

这里就是我们的不是为我工作:

export async function msLogin() {
  const userAgent = new MSAL.UserAgentApplication({ auth: { clientId: CLIENT_ID, } });
  const auth = await userAgent.loginPopup({ scopes: ['profile'] });
  const provider = new firebase.auth.OAuthProvider('microsoft.com');
  const idToken = auth.idToken.rawIdToken;
  const credential = provider.credential(idToken);

  await firebase.auth().signInWithCredential(credential); // **** THIS FAILS
  // ... with "Invalid IdP response/credential: http://localhost?id_token=eyJ0eXAiO...0e9BeTObQ&providerId=microsoft.com"

Run Code Online (Sandbox Code Playgroud)

微软弹出部分运行良好,我在那里成功登录并能够发出 API 调用。但是我无法让 firebase 接受这些凭据来登录 firebase。我已在 Firebase 身份验证面板中启用了 Microsoft OAuth 提供程序,并且我确定 CLIENT_ID 的匹配...

也许我构建OAuthCredential错误?

非常感谢帮助!

ps:这是这篇SO帖子的延续。