The auth/missing-phone-number error occurs when calling Firebase phone authentication methods without providing a valid phone number. This is thrown when the phone number parameter is missing or not passed to signInWithPhoneNumber or verifyPhoneNumber.
Firebase Authentication throws the auth/missing-phone-number error when you attempt to authenticate a user via phone number but fail to provide a phone number string to the authentication method. This error indicates that the required phone number parameter is either missing, null, undefined, or empty in your authentication function call. Firebase requires a properly formatted phone number (including country code) to initiate phone-based authentication via SMS verification. This validation happens client-side in your application code before the request even reaches Firebase servers. It prevents invalid authentication attempts and helps maintain the integrity of your phone authentication flow.
Add a simple check to ensure the phone number is not empty or null before calling the Firebase authentication method:
const phoneNumber = userInput.trim();
if (!phoneNumber || phoneNumber.length === 0) {
console.error('Phone number is required');
setError('Please enter a valid phone number');
return;
}
try {
const confirmationResult = await signInWithPhoneNumber(
auth,
phoneNumber
);
} catch (error) {
console.error('Authentication failed:', error.code);
}This prevents the auth/missing-phone-number error by validating input before the Firebase call.
Firebase requires phone numbers to be formatted with a country code prefix (e.g., +1 for US, +44 for UK). Make sure your input validation includes this:
const phoneNumber = userInput.trim();
// Ensure phone number starts with +
if (!phoneNumber.startsWith('+')) {
setError('Phone number must include country code (e.g., +1 for US)');
return;
}
if (phoneNumber.length < 10) {
setError('Phone number is too short');
return;
}
await signInWithPhoneNumber(auth, phoneNumber);Before implementing phone authentication, you must enable it in your Firebase project:
1. Go to the Firebase Console (console.firebase.google.com)
2. Select your project
3. Navigate to Authentication section
4. Click on "Sign-in method" tab
5. Find "Phone Number" in the list
6. Click the toggle to enable it
7. Click "Save"
Without this enabled, all phone authentication attempts will fail. This is a project-level configuration, not code-level.
Wrap your phone authentication call in try-catch and handle specific error codes:
try {
const phoneNumber = form.phoneInput.value.trim();
if (!phoneNumber) {
throw new Error('Phone number is required');
}
const confirmationResult = await signInWithPhoneNumber(
auth,
phoneNumber
);
// Store for later use
window.confirmationResult = confirmationResult;
} catch (error: any) {
switch(error.code) {
case 'auth/missing-phone-number':
setError('Please enter your phone number');
break;
case 'auth/invalid-phone-number':
setError('Phone number format is invalid');
break;
case 'auth/quota-exceeded':
setError('Too many requests. Please try again later');
break;
default:
setError(error.message);
}
}Firebase allows you to register test phone numbers in the console to test without sending real SMS messages:
1. In Firebase Console, go to Authentication > Sign-in method
2. Expand the "Phone" provider
3. Click on "Phone numbers for testing"
4. Add a test phone number (e.g., +1 650-555-3434) and verification code
5. In your app, when you use a registered test number, entering the test code will authenticate without sending SMS
Example test numbers you can use:
- +1 650-555-3434 (US format)
- +44 7444 555666 (UK format)
- +81 90-1234-5678 (Japan format)
Test numbers prevent quota issues and let you verify your authentication flow works correctly.
The auth/missing-phone-number error is a validation error that happens before Firebase servers are contacted. It's different from auth/invalid-phone-number, which means the phone number format is wrong (e.g., missing country code, wrong length). The error occurs at the client-side validation stage, so if you're seeing this, your Firebase configuration is correct but your input handling needs fixing.
In web applications, Firebase uses reCAPTCHA as part of phone authentication. Make sure your domain is whitelisted in Firebase Console under Authentication > Settings > Authorized domains. On mobile (iOS/Android), the validation happens through the native Firebase SDK with similar requirements.
If you're building a reusable phone input component, consider creating a utility function that formats and validates phone numbers before passing them to Firebase:
Callable Functions: INTERNAL - Unhandled exception
How to fix "Callable Functions: INTERNAL - Unhandled exception" in Firebase
messaging/UNSPECIFIED_ERROR: No additional information available
How to fix "messaging/UNSPECIFIED_ERROR: No additional information available" in Firebase Cloud Messaging
auth/invalid-hash-algorithm: Hash algorithm doesn't match supported options
How to fix "auth/invalid-hash-algorithm: Hash algorithm doesn't match supported options" in Firebase
App Check: reCAPTCHA Score Too Low
App Check reCAPTCHA Score Too Low
storage/invalid-url: Invalid URL format for Cloud Storage reference
How to fix invalid URL format in Firebase Cloud Storage