Home > @firebase/auth > signInWithPopup
signInWithPopup() function
Authenticates a Firebase client using a popup-based OAuth authentication flow.
Signature:
export declare function signInWithPopup(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
Parameters
Parameter | Type | Description |
---|---|---|
auth | Auth | The Auth instance. |
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 succeeds, returns the signed in user along with the provider's credential. If sign in was unsuccessful, returns an error object containing additional information about the error.
Example
// Sign in using a popup.
const provider = new FacebookAuthProvider();
const result = await signInWithPopup(auth, provider);
// The signed-in user info.
const user = result.user;
// This gives you a Facebook Access Token.
const credential = provider.credentialFromResult(auth, result);
const token = credential.accessToken;