Home > @firebase/auth > linkWithPopup
linkWithPopup() function
Links the authenticated provider to the user account using a pop-up based OAuth flow.
Signature:
export declare function linkWithPopup(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
Parameters
Parameter | Type | Description |
---|---|---|
user | User | The user. |
provider | AuthProvider | The provider to authenticate. The provider has to be an OAuthProvider. Non-OAuth providers like EmailAuthProvider will throw an error. |
resolver | PopupRedirectResolver | An instance of PopupRedirectResolver, optional if already supplied to initializeAuth() or provided by getAuth(). |
Returns:
Promise<UserCredential>
Description
If the linking is successful, the returned result will contain the user and the provider's credential.
Example
// Sign in using some other provider.
const result = await signInWithEmailAndPassword(auth, email, password);
// Link using a popup.
const provider = new FacebookAuthProvider();
await linkWithPopup(result.user, provider);