首页 > 解决方案 > FireBase Auth SignOut:PlatformException(FirebaseException,用户已经链接到给定的提供者。,null)

问题描述

我正在为用户进行firebase身份验证。我同时使用谷歌和手机登录。用户已成功通过身份验证并像这样登录。

在此处输入图像描述

但是当我从应用程序中注销,并尝试使用相同的谷歌和手机再次登录时,它告诉我 -

短信验证码失败:PlatformException(FirebaseException, User has been linked to the given provider., null)

我已使用以下代码从应用程序中注销。

FlatButton(
              child: Text("Sign out", style: theme.textTheme.button),
              onPressed: () async {
                await GoogleSignIn().signOut();             
                await FirebaseAuth.instance.signOut();

              },
            )

标签: firebaseauthenticationflutterfirebase-authentication

解决方案


好吧,这个问题是通过从 firebase auth 控制台中删除 firebase 用户来解决的。

希望我在firestore数据库中有链接到该帐户的数据,当他尝试在一段时间后登录并通过搜索密钥(电话号码)检索他以前的数据时,我用来再次验证该用户。

final FirebaseUser firebaseUser;
final GoogleSignInAccount googleUser;
 onPressed: () async {
                await GoogleSignIn().signOut();
                googleUser.clearAuthCache();
                print('SignedOut');
                await firebaseUser.delete();
                await FirebaseAuth.instance.signOut();                
                print('signedOut from FireBase');                
              }

这个问题得到了解决,而不会对与用户链接的数据造成任何损坏。


推荐阅读