I’m using flutter and google sign in through firebase ( mobile app) with laravel backend, the app is connected through api website url
the issue is when i login with google auth it works well and when i logout i cant login again i got this error msg in android studio terminal firebase_auth/provider-already-linked]?
if i delete the user from my back end db i can login again
here is my code if anyone has an idea ?
Future<User> signInWithGoogle(BuildContext context) async {
final GoogleSignIn googleSignIn = GoogleSignIn();
GoogleSignInAccount? googleSignInAccount = await googleSignIn.signIn();
if (googleSignInAccount != null) {
final GoogleSignInAuthentication googleSignInAuthentication = await googleSignInAccount.authentication;
final AuthCredential credential = GoogleAuthProvider.credential(
accessToken: googleSignInAuthentication.accessToken,
idToken: googleSignInAuthentication.idToken,
);
final UserCredential authResult = await FirebaseAuth.instance.signInWithCredential(credential);
final User user = authResult.user!;
assert(!user.isAnonymous);
final User currentUser = FirebaseAuth.instance.currentUser!;
assert(user.uid == currentUser.uid);
try {
AuthCredential emailAuthCredential = EmailAuthProvider.credential(email: user.email!, password: DEFAULT_FIREBASE_PASSWORD);
user.linkWithCredential(emailAuthCredential);
} catch (e) {
log(e);
}
await googleSignIn.signOut();
return user;
} else {
appStore.setLoading(false);
throw USER_NOT_CREATED;
}
}