flutter - 如何在 Flutter 移动应用程序中将 Azure AD 用户登录到 Firebase?

标签 flutter firebase-authentication azure-active-directory

对于 Flutter 移动应用程序,我尝试使用 Microsoft OAuthProvider 获取 Firebase 凭据,使用该凭据将用户与他们的 Azure AD 帐户登录到 Firebase。
我得到的最接近的是使用 third party Active Directory auth package登录用户并获取访问 token 。但是,登录 Firebase 失败并显示一条错误消息,表明 idToken 无效。

final AadOAuth oauth = new AadOAuth(config);
await oauth.login();

// accessToken looks legit
String accessToken = await oauth.getAccessToken();

String idToken = await oauth.getIdToken();

OAuthProvider provider = OAuthProvider('microsoft.com');

// Also tried the constructor without the idToken
OAuthCredential credential = provider.credential(accessToken: accessToken, idToken: idToken);

// app fails here:
await FirebaseAuth.instance.signInWithCredential(credential);

// this works fine, but only on web platform:
await FirebaseAuth.instance.signInWithPopup(provider);
因为它是平台特定的错误(在这种情况下为 iOS),所以不会显示异常详细信息。我得到的是:

PlatformException(internal-error, ) nativeErrorCode: 17999


这是我在 Azure 门户中的应用设置:
screenshot
完整 list here
有没有人成功地使用 Microsoft Auth 在 Flutter 移动应用程序中将用户登录到 Firebase?

最佳答案

您可以使用 Firebase Auth OAuth为它打包。
并使用 Microsoft Auth 提供程序登录 Firebase。

User user = await FirebaseAuthOAuth().openSignInFlow(
  "microsoft.com", ["email openid"], {'tenant': 'your-tenent-id'});
这与 firebase 很好地集成在一起,所以 firebase authStateChange也适用于这种方法。

关于flutter - 如何在 Flutter 移动应用程序中将 Azure AD 用户登录到 Firebase?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64066566/

相关文章:

flutter - 如何测试流是否在Dart中的特定位置发出值?

ios - Firebase - iOS Swift : FIRAuth. auth().signOut() 未注销当前用户

azure-active-directory - 企业应用程序中基于组角色的授权

Flutter-如何在一行中的特定位置对齐按钮?

firebase - Flutter Firebase 时间戳

ios - 如何在所有 iPhone 模拟器上使用 Firebase 登录 iOS Google?

c# - 使用 MSAL 获取 claim

azure-active-directory - Azure AD 中的 Auth0 和 JWT 之间有什么区别(在 Azure AD 中使用访问 token 的最佳实践)?

dart - 在同一台机器上更改 Flutter/Dart 的 uploader

android - 为个人用户组织 Firebase 数据库,想法?