如何在Flutter移动应用中将Azure AD用户登录到Firebase? [英] How to sign a Azure AD user into Firebase in a Flutter mobile app?

查看:76
本文介绍了如何在Flutter移动应用中将Azure AD用户登录到Firebase?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Flutter移动应用程序,我正在尝试使用Microsoft OAuthProvider获取Firebase凭据,以该凭据将用户使用其Azure AD帐户登录到Firebase.

我最近得到的是使用

有人成功使用Microsoft Auth在Flutter移动应用中将用户登录到Firebase吗?

解决方案

您可以使用 Firebase Auth OAuth 打包.

然后使用Microsoft Auth提供程序登录到Firebase.

 用户=等待FirebaseAuthOAuth().openSignInFlow(" microsoft.com",["电子邮件openid"],{'tenant':'your-tenent-id'})); 

这与firebase很好地集成在一起,因此,firebase authStateChange 也可以与此方法一起使用.

For a Flutter mobile app I am trying to use a Microsoft OAuthProvider to get a Firebase credential with which to sign the user into Firebase with their Azure AD account.

The closest I got was using a third party Active Directory auth package to log the user in and get an access token. However the sign-in to Firebase fails with an error message that suggests the idToken is invalid.

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);

Because it is a platform specific error (iOS in this case), the exception details are not surfaced. All I get is:

PlatformException(internal-error, ) nativeErrorCode: 17999

Here is my app settings in the Azure portal:

Full manifest here

Has anyone been successful in using Microsoft Auth to sign a user in to Firebase in a Flutter mobile app?

解决方案

You can use Firebase Auth OAuth package for it.

And sign in to the firebase using the Microsoft Auth provider.

User user = await FirebaseAuthOAuth().openSignInFlow(
  "microsoft.com", ["email openid"], {'tenant': 'your-tenent-id'});

This integrates nicely with firebase so, firebase authStateChange also works with this method.

这篇关于如何在Flutter移动应用中将Azure AD用户登录到Firebase?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆