Back to Firebase Js Sdk

EmailAuthProvider class

docs-devsite/auth.emailauthprovider.md

12.12.14.7 KB
Original Source

Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference

{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}

EmailAuthProvider class

Provider for generating EmailAuthCredential<!-- -->.

<b>Signature:</b>

typescript
export declare class EmailAuthProvider implements AuthProvider 

<b>Implements:</b> AuthProvider

Properties

PropertyModifiersTypeDescription
EMAIL_LINK_SIGN_IN_METHOD<code>static</code>'emailLink'Always set to SignInMethod<!-- -->.EMAIL_LINK.
EMAIL_PASSWORD_SIGN_IN_METHOD<code>static</code>'password'Always set to SignInMethod<!-- -->.EMAIL_PASSWORD.
PROVIDER_ID<code>static</code>'password'Always set to ProviderId<!-- -->.PASSWORD, even for email link.
providerId"password"Always set to ProviderId<!-- -->.PASSWORD, even for email link.

Methods

MethodModifiersDescription
credential(email, password)<code>static</code>Initialize an AuthCredential using an email and password.
credentialWithLink(email, emailLink)<code>static</code>Initialize an AuthCredential using an email and an email link after a sign in with email link operation.

Always set to SignInMethod<!-- -->.EMAIL_LINK.

<b>Signature:</b>

typescript
static readonly EMAIL_LINK_SIGN_IN_METHOD: 'emailLink';

EmailAuthProvider.EMAIL_PASSWORD_SIGN_IN_METHOD

Always set to SignInMethod<!-- -->.EMAIL_PASSWORD.

<b>Signature:</b>

typescript
static readonly EMAIL_PASSWORD_SIGN_IN_METHOD: 'password';

EmailAuthProvider.PROVIDER_ID

Always set to ProviderId<!-- -->.PASSWORD, even for email link.

<b>Signature:</b>

typescript
static readonly PROVIDER_ID: 'password';

EmailAuthProvider.providerId

Always set to ProviderId<!-- -->.PASSWORD, even for email link.

<b>Signature:</b>

typescript
readonly providerId: "password";

EmailAuthProvider.credential()

Initialize an AuthCredential using an email and password.

<b>Signature:</b>

typescript
static credential(email: string, password: string): EmailAuthCredential;

Parameters

ParameterTypeDescription
emailstringEmail address.
passwordstringUser account password.

<b>Returns:</b>

EmailAuthCredential

The auth provider credential.

Example 1

javascript
const authCredential = EmailAuthProvider.credential(email, password);
const userCredential = await signInWithCredential(auth, authCredential);

Example 2

javascript
const userCredential = await signInWithEmailAndPassword(auth, email, password);

Initialize an AuthCredential using an email and an email link after a sign in with email link operation.

<b>Signature:</b>

typescript
static credentialWithLink(email: string, emailLink: string): EmailAuthCredential;

Parameters

ParameterTypeDescription
emailstringEmail address.
emailLinkstringSign-in email link.

<b>Returns:</b>

EmailAuthCredential

  • The auth provider credential.

Example 1

javascript
const authCredential = EmailAuthProvider.credentialWithLink(auth, email, emailLink);
const userCredential = await signInWithCredential(auth, authCredential);

Example 2

javascript
await sendSignInLinkToEmail(auth, email);
// Obtain emailLink from user.
const userCredential = await signInWithEmailLink(auth, email, emailLink);