使用 react-native-firebase/auth OAuth 提供程序来验证 Azure AD 凭据

Use react-native-firebase/auth OAuth provider to auth Azure AD credential

我正在开发一款带有 react-native (react-native-firebase/auth) 的手机,并使用 Firebase Auth 来管理用户登录。一开始,我只使用 email/password 来验证用户并且工作得很好。

现在我想让用户使用Azure AD。由于react-native-firebase/auth暂时不支持微软账号,所以我使用react-native-app-auth。然后,使用 Microsoft 凭据对 Firebase 用户进行身份验证,然后 link 他们一起。

const result = await authorize(config);
const credential = auth.OAuthProvider.credential(
  result.idToken,
  result.accessToken,
);
const userCredential = await auth().signInWithCredential(credential);

调用 signInWithCredential 时,抛出错误:[auth/internal-error].

目前,我有类似于 Firebase 用户帐户的后端用户配置文件。我不想使后端复杂化以具有多种身份验证方法。理想情况下,它可以在 Firebase 上完成就太好了。

谢谢。

看来您必须使用自定义令牌。

Unlike other OAuth providers supported by Firebase such as Google, Facebook, and Twitter, where sign-in can directly be achieved with OAuth access token based credentials, Firebase Auth does not support the same capability for providers such as Microsoft due to the inability of the Firebase Auth server to verify the audience of Microsoft OAuth access tokens.

If these providers are required to be used in unsupported environments, a third party OAuth library and Firebase custom authentication would need to be used.

source: Firebase doc