UNPKG

voluptasmollitia

Version:
58 lines (40 loc) 2.17 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@firebase/auth](./auth.md) &gt; [getRedirectResult](./auth.getredirectresult.md) ## getRedirectResult() function Returns a [UserCredential](./auth.usercredential.md) from the redirect-based sign-in flow. <b>Signature:</b> ```typescript export declare function getRedirectResult(auth: Auth, resolver?: PopupRedirectResolver): Promise<UserCredential | null>; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | auth | [Auth](./auth.auth.md) | The Auth instance. | | resolver | [PopupRedirectResolver](./auth.popupredirectresolver.md) | An instance of [PopupRedirectResolver](./auth.popupredirectresolver.md)<!-- -->, optional if already supplied to [initializeAuth()](./auth.initializeauth.md) or provided by [getAuth()](./auth.getauth.md)<!-- -->. | <b>Returns:</b> Promise&lt;[UserCredential](./auth.usercredential.md) \| null&gt; ## Remarks If sign-in succeeded, returns the signed in user. If sign-in was unsuccessful, fails with an error. If no redirect operation was called, returns a [UserCredential](./auth.usercredential.md) with a null `user`<!-- -->. ## Example ```javascript // Sign in using a redirect. const provider = new FacebookAuthProvider(); // You can add additional scopes to the provider: provider.addScope('user_birthday'); // Start a sign in process for an unauthenticated user. await signInWithRedirect(auth, provider); // This will trigger a full page redirect away from your app // After returning from the redirect when your app initializes you can obtain the result const result = await getRedirectResult(auth); if (result) { // This is the signed-in user const user = result.user; // This gives you a Facebook Access Token. const credential = provider.credentialFromResult(auth, result); const token = credential.accessToken; } // As this API can be used for sign-in, linking and reauthentication, // check the operationType to determine what triggered this redirect // operation. const operationType = result.operationType; ```