Phone number auth provider.

example
// 'recaptcha-container' is the ID of an element in the DOM.var applicationVerifier =new firebase.auth.RecaptchaVerifier('recaptcha-container');var provider =new firebase.auth.PhoneAuthProvider();provider.verifyPhoneNumber('+16505550101', applicationVerifier)    .then(function(verificationId){var verificationCode =window.prompt('Please enter the verification ' +'code that was sent to your mobile device.');return firebase.auth.PhoneAuthProvider.credential(verificationId,          verificationCode);    })    .then(function(phoneCredential){return firebase.auth().signInWithCredential(phoneCredential);    });
param

The Firebase Auth instance in whichsign-ins should occur. Uses the default Auth instance if unspecified.

Implements

Index

Constructors

constructor

Properties

providerId

providerId:string

Implementation ofAuthProvider.providerId

Inherited fromPhoneAuthProvider.providerId

Static PHONE_SIGN_IN_METHOD

PHONE_SIGN_IN_METHOD:string

This corresponds to the sign-in method identifier as returned infirebase.auth.Auth.fetchSignInMethodsForEmail.

Static PROVIDER_ID

PROVIDER_ID:string

Methods

verifyPhoneNumber

  • verifyPhoneNumber(phoneInfoOptionsPhoneInfoOptions |string, applicationVerifierApplicationVerifier):Promise<string>
  • Inherited fromPhoneAuthProvider.verifyPhoneNumber

    Starts a phone number authentication flow by sending a verification code tothe given phone number. Returns an ID that can be passed tofirebase.auth.PhoneAuthProvider.credential to identify this flow.

    For abuse prevention, this method also requires afirebase.auth.ApplicationVerifier. The Firebase Auth SDK includesa reCAPTCHA-based implementation,firebase.auth.RecaptchaVerifier.

    Error Codes

    auth/captcha-check-failed
    Thrown if the reCAPTCHA response token was invalid, expired, or ifthis method was called from a non-whitelisted domain.
    auth/invalid-phone-number
    Thrown if the phone number has an invalid format.
    auth/missing-phone-number
    Thrown if the phone number is missing.
    auth/quota-exceeded
    Thrown if the SMS quota for the Firebase project has been exceeded.
    auth/user-disabled
    Thrown if the user corresponding to the given phone number has beendisabled.
    auth/maximum-second-factor-count-exceeded
    Thrown if The maximum allowed number of second factors on a userhas been exceeded.
    auth/second-factor-already-in-use
    Thrown if the second factor is already enrolled on this account.
    auth/unsupported-first-factor
    Thrown if the first factor being used to sign in is not supported.
    auth/unverified-email
    Thrown if the email of the account is not verified.

    Parameters

    ReturnsPromise<string>

    A Promise for the verification ID.

Static credential

  • credential(verificationIdstring, verificationCodestring):AuthCredential
  • Creates a phone auth credential, given the verification ID fromfirebase.auth.PhoneAuthProvider.verifyPhoneNumber and the codethat was sent to the user's mobile device.

    Error Codes

    auth/missing-verification-code
    Thrown if the verification code is missing.
    auth/missing-verification-id
    Thrown if the verification ID is missing.

    Parameters

    ReturnsAuthCredential

    The auth provider credential.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2022-07-27 UTC.