Stay organized with collections
Save and categorize content based on your preferences.
Properties
providerId
providerId: string
Static PHONE_SIGN_IN_METHOD
PHONE_SIGN_IN_METHOD: string
Static PROVIDER_ID
PROVIDER_ID: string
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-07-27 UTC.
[null,null,["Last updated 2022-07-27 UTC."],[],[],null,["- [firebase](/docs/reference/node/firebase).\n- [auth](/docs/reference/node/firebase.auth).\n- PhoneAuthProvider \nPhone number auth provider.\n\nexample\n:\n\n // 'recaptcha-container' is the ID of an element in the DOM.\n var applicationVerifier = new firebase.auth.RecaptchaVerifier(\n 'recaptcha-container');\n var provider = new firebase.auth.PhoneAuthProvider();\n provider.verifyPhoneNumber('+16505550101', applicationVerifier)\n .then(function(verificationId) {\n var verificationCode = window.prompt('Please enter the verification ' +\n 'code that was sent to your mobile device.');\n return firebase.auth.PhoneAuthProvider.credential(verificationId,\n verificationCode);\n })\n .then(function(phoneCredential) {\n return firebase.auth().signInWithCredential(phoneCredential);\n });\n\n\nparam\n\n: The Firebase Auth instance in which\n sign-ins should occur. Uses the default Auth instance if unspecified.\n\nImplements\n\n- [AuthProvider](/docs/reference/node/firebase.auth.AuthProvider)\n\nIndex\n\nConstructors\n\n- [constructor](/docs/reference/node/firebase.auth.PhoneAuthProvider#constructor)\n\nProperties\n\n- [providerId](/docs/reference/node/firebase.auth.PhoneAuthProvider#providerid)\n- [PHONE_SIGN_IN_METHOD](/docs/reference/node/firebase.auth.PhoneAuthProvider#phone_sign_in_method)\n- [PROVIDER_ID](/docs/reference/node/firebase.auth.PhoneAuthProvider#provider_id)\n\nMethods\n\n- [verifyPhoneNumber](/docs/reference/node/firebase.auth.PhoneAuthProvider#verifyphonenumber)\n- [credential](/docs/reference/node/firebase.auth.PhoneAuthProvider#credential)\n\nConstructors\n\nconstructor\n\n- new PhoneAuthProvider ( auth ? : [Auth](/docs/reference/node/firebase.auth.Auth) \\| null ) : [PhoneAuthProvider](/docs/reference/node/firebase.auth.PhoneAuthProvider)\n-\n | Inherited from [PhoneAuthProvider](/docs/reference/node/firebase.auth.PhoneAuthProvider).[constructor](/docs/reference/node/firebase.auth.PhoneAuthProvider#constructor)\n\n Parameters\n -\n\n Optional auth: [Auth](/docs/reference/node/firebase.auth.Auth) \\| null\n\n Returns [PhoneAuthProvider](/docs/reference/node/firebase.auth.PhoneAuthProvider)\n\nProperties\n\nproviderId \nproviderId: string\n| Implementation of [AuthProvider](/docs/reference/node/firebase.auth.AuthProvider).[providerId](/docs/reference/node/firebase.auth.AuthProvider#providerid)\n| Inherited from [PhoneAuthProvider](/docs/reference/node/firebase.auth.PhoneAuthProvider).[providerId](/docs/reference/node/firebase.auth.PhoneAuthProvider#providerid)\n\nStatic PHONE_SIGN_IN_METHOD \nPHONE_SIGN_IN_METHOD: string \nThis corresponds to the sign-in method identifier as returned in\n[firebase.auth.Auth.fetchSignInMethodsForEmail](/docs/reference/node/firebase.auth.Auth#fetchsigninmethodsforemail).\n\nStatic PROVIDER_ID \nPROVIDER_ID: string\n\nMethods\n\nverifyPhoneNumber\n\n- verifyPhoneNumber ( phoneInfoOptions : [PhoneInfoOptions](/docs/reference/node/firebase.auth#phoneinfooptions) \\| string , applicationVerifier : [ApplicationVerifier](/docs/reference/node/firebase.auth.ApplicationVerifier) ) : Promise \\\u003c string \\\u003e\n-\n Inherited from [PhoneAuthProvider](/docs/reference/node/firebase.auth.PhoneAuthProvider).[verifyPhoneNumber](/docs/reference/node/firebase.auth.PhoneAuthProvider#verifyphonenumber) \n Starts a phone number authentication flow by sending a verification code to\n the given phone number. Returns an ID that can be passed to\n [firebase.auth.PhoneAuthProvider.credential](/docs/reference/node/firebase.auth.PhoneAuthProvider#credential) to identify this flow.\n\n For abuse prevention, this method also requires a\n [firebase.auth.ApplicationVerifier](/docs/reference/node/firebase.auth.ApplicationVerifier). The Firebase Auth SDK includes\n a reCAPTCHA-based implementation, firebase.auth.RecaptchaVerifier.\n\n Error Codes\n\n auth/captcha-check-failed\n : Thrown if the reCAPTCHA response token was invalid, expired, or if\n this method was called from a non-whitelisted domain.\n\n auth/invalid-phone-number\n : Thrown if the phone number has an invalid format.\n\n auth/missing-phone-number\n : Thrown if the phone number is missing.\n\n auth/quota-exceeded\n : Thrown if the SMS quota for the Firebase project has been exceeded.\n\n auth/user-disabled\n : Thrown if the user corresponding to the given phone number has been\n disabled.\n\n auth/maximum-second-factor-count-exceeded\n : Thrown if The maximum allowed number of second factors on a user\n has been exceeded.\n\n auth/second-factor-already-in-use\n : Thrown if the second factor is already enrolled on this account.\n\n auth/unsupported-first-factor\n : Thrown if the first factor being used to sign in is not supported.\n\n auth/unverified-email\n : Thrown if the email of the account is not verified.\n\n Parameters\n -\n\n phoneInfoOptions: [PhoneInfoOptions](/docs/reference/node/firebase.auth#phoneinfooptions) \\| string \n The user's [firebase.auth.PhoneInfoOptions](/docs/reference/node/firebase.auth#phoneinfooptions).\n The phone number should be in E.164 format (e.g. +16505550101).\n -\n\n applicationVerifier: [ApplicationVerifier](/docs/reference/node/firebase.auth.ApplicationVerifier)\n\n Returns Promise\\\u003cstring\\\u003e\n\n A Promise for the verification ID.\n\nStatic credential\n\n- credential ( verificationId : string , verificationCode : string ) : [AuthCredential](/docs/reference/node/firebase.auth.AuthCredential)\n- Creates a phone auth credential, given the verification ID from\n [firebase.auth.PhoneAuthProvider.verifyPhoneNumber](/docs/reference/node/firebase.auth.PhoneAuthProvider#verifyphonenumber) and the code\n that was sent to the user's mobile device.\n\n Error Codes\n\n auth/missing-verification-code\n : Thrown if the verification code is missing.\n\n auth/missing-verification-id\n : Thrown if the verification ID is missing.\n\n Parameters\n -\n\n verificationId: string \n The verification ID returned from\n [firebase.auth.PhoneAuthProvider.verifyPhoneNumber](/docs/reference/node/firebase.auth.PhoneAuthProvider#verifyphonenumber).\n -\n\n verificationCode: string \n The verification code sent to the user's\n mobile device.\n\n Returns [AuthCredential](/docs/reference/node/firebase.auth.AuthCredential)\n\nThe auth provider credential."]]
Phone number auth provider.
// '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); });
The Firebase Auth instance in which sign-ins should occur. Uses the default Auth instance if unspecified.