The Firebase JS SDK is now in BETA!
This EAP site is no longer maintained. See the official Firebase Documentation site for the latest documentation and information about the Firebase JS SDK.

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;