You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/auth/social-auth.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -380,3 +380,34 @@ Additionally, the similar `linkWithRedirect` and `linkWithPopup` methods may be
380
380
381
381
Upon successful sign-in, any [`onAuthStateChanged`](/auth/usage#listening-to-authentication-state) listeners will trigger
382
382
with the new authentication state of the user.
383
+
384
+
## Link Multiple Auth Providers to a Firebase Account
385
+
386
+
[From the official documentation:](https://firebase.google.com/docs/auth/web/google-signin#expandable-1)
387
+
388
+
> If you enabled the **One account per email address** setting in the Firebase console, when a user tries to sign in a to a provider (such as Google) with an email that already exists for another Firebase user's provider (such as Facebook), the error `auth/account-exists-with-different-credential` is thrown along with an `AuthCredential` object (Google ID token). To complete the sign in to the intended provider, the user has to sign first to the existing provider (Facebook) and then link to the former `AuthCredential` (Google ID token).
389
+
390
+
To provide users with an additional login method, you can link their social media account (or an email & password) with their Firebase account. This is possible for any social provider that uses `auth().signInWithCredential()`.
391
+
To achieve this, you should replace sign-in method in any of the supported social sign-in code snippets with `auth().currentUser.linkWithCredential()`.
392
+
393
+
This code demonstrates linking a Google provider to an account that is already signed in using Firebase authentication.
0 commit comments