热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Flutter如何使用FirebaseFacebook和Google插件链接社交帐户

我有一个流畅的应用程序,希望用户同时通过FB和Google进行身份验证。我不希望有

我有一个流畅的应用程序,希望用户同时通过FB和Google进行身份验证。我不希望有多个帐户,而只需要一个链接两个帐户的帐户。

我正在使用:

firebase_auth 0.15.1

google_sign_in 4.0.14

facebook_plugin 3.0.0

当该用户的帐户已经存在于其他提供商处时,我无法获得该用户的电子邮件地址。为了使用API​​调用“ fetchSignInmethodsForEmail”获得该用户的提供者列表,需要使用该电子邮件。

这里是一个示例:
1:使用Google凭据登录的用户。该帐户是在Firebase中创建的,并且已关联Google
2:用户现在注销
3:用户现在尝试使用相同的电子邮件登录FB。

-用户遇到以下错误

code:"ERROR_accOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL"
details: null
message: "An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.,**null**))

如您所见,电子邮件为空。我需要电子邮件以获取提供商列表。然后,我可以将用户重定向到正确的提供程序

这是我的代码段

Future signInWithFacebook({bool isIos}) async {
AuthCredential credential;
try {
final FacebookLoginResult result = await facebookLogin.logIn(['email']);
if (result.accessToken != null) {
credential = FacebookAuthProvider.getcredential(
accessToken: result.accessToken.token
);
AuthResult authResult = await _firebaseAuth.signInWithCredential(
credential,);
firebaseUser = authResult.user;
return firebaseUser;
} catch (e) {
throw Exception(e);
}
return null;
}

感谢您的帮助





推荐阅读
author-avatar
手机用户2502914387
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有