How to fix auth/invalid-argument: Invalid parameter passed to method in Firebase
This error occurs when you pass invalid parameters to Firebase Authentication methods. Common causes include empty strings, null values, wrong parameter types, or incorrect method syntax. Most fixes involve validating inputs before passing them to Firebase functions.
Quick fix
Fixes auth/invalid-argument: Invalid parameter passed to method
import { getAuth, signInWithEmailAndPassword } from 'firebase/auth';
const auth = getAuth();
const email = userInput.email?.trim();
const password = userInput.password?.trim();
// WRONG: May have empty strings
// signInWithEmailAndPassword(auth, email, password);
// RIGHT: Validate first
if (!email || !password) {
console.error("Email and password are required");
return;
}
signInWithEmailAndPassword(auth, email, password)
.catch((error) => console.error(error.message));- Verify parameters are not empty
- Check Firebase SDK version and syntax consistency
- Validate parameter types and order
- Ensure Firebase is initialized before use
import { getAuth, signInWithEmailAndPassword } from 'firebase/auth';const auth = getAuth();const email = userInput.email?.trim();const password = userInput.password?.trim();// WRONG: May have empty strings// signInWithEmailAndPassword(auth, email, password);// RIGHT: Validate firstif (!email || !password) {console.error("Email and password are required");return;}signInWithEmailAndPassword(auth, email, password).catch((error) => console.error(error.message));auth/invalid-argument: Invalid parameter passed to method
What this error means
Firebase Authentication throws the "invalid-argument: Invalid parameter passed to method" error when one or more parameters provided to an auth method don't meet the method's requirements. This is a validation error that occurs before Firebase attempts authentication. The error typically indicates that: 1. A required parameter is missing, empty, or null 2. A parameter has the wrong data type (e.g., passing an object when a string is expected) 3. Parameter order is incorrect 4. You're mixing different Firebase SDK versions with incompatible syntax This is distinct from authentication failures (wrong password) or credential issues (expired tokens) — it's a function call error.
Typical symptoms
- Firebase authentication method throws an error immediately without attempting connection
- Error appears during development, not just in production
- The error occurs consistently on the same line of code
- Error mentions specific parameter name or position (sometimes)
- Works in some environments but fails in others (version mismatch)
Common causes
- Passing empty strings or null/undefined values to required parameters like email or password
- Using Firebase v9+ modular SDK syntax with v8 compat code or vice versa
- Incorrect parameter order (e.g., passing password before email)
- Parameter type mismatch (passing an object when a string is expected)
- Auth instance not initialized before calling methods
- Mixing imports from incompatible Firebase SDK versions
- Passing special characters or invalid formats without validation
How to fix "auth/invalid-argument: Invalid parameter passed to method"
Check that all required parameters are non-empty strings before passing to Firebase auth methods.
import { getAuth, signInWithEmailAndPassword } from 'firebase/auth';
const auth = getAuth();
const email = userInput.email?.trim();
const password = userInput.password?.trim();
// WRONG: May have empty strings
// signInWithEmailAndPassword(auth, email, password);
// RIGHT: Validate first
if (!email || !password) {
console.error("Email and password are required");
return;
}
signInWithEmailAndPassword(auth, email, password)
.catch((error) => console.error(error.message));Empty strings pass JavaScript's truthiness check (if (email) fails), so explicitly check length or use .trim().
Ensure you're using consistent Firebase SDK syntax throughout your project.
Firebase v9+ (Modular) - Recommended:
import { getAuth, signInWithEmailAndPassword } from 'firebase/auth';
const auth = getAuth();
signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => console.log(userCredential.user))
.catch((error) => console.error(error.code, error.message));Firebase v8 (Compat) - Legacy:
import firebase from 'firebase/app';
import 'firebase/auth';
firebase.auth().signInWithEmailAndPassword(email, password)
.then((userCredential) => console.log(userCredential.user))
.catch((error) => console.error(error.code, error.message));Do NOT mix both styles in the same project. Pick one and use it consistently. If you're starting new, use v9+ (modular).
Verify you're passing parameters in the correct order with the correct types.
// WRONG: Parameter order incorrect
signInWithEmailAndPassword(password, auth, email);
// WRONG: Missing auth parameter (v9+)
signInWithEmailAndPassword(email, password);
// WRONG: Passing object instead of auth instance
signInWithEmailAndPassword({auth}, email, password);
// CORRECT: auth instance first, then email, then password
signInWithEmailAndPassword(auth, email, password);For other methods, refer to Firebase docs for the exact parameter order and types:
- createUserWithEmailAndPassword(auth, email, password)
- signInWithPhoneNumber(phoneNumber, appVerifier) - Not signInWithPhone
- signOut(auth) - No email/password needed
- updateEmail(user, newEmail) - Requires user instance
Firebase Auth methods require a properly initialized auth instance.
import { initializeApp } from 'firebase/app';
import { getAuth } from 'firebase/auth';
// Initialize Firebase first
const app = initializeApp({
apiKey: "YOUR_API_KEY",
projectId: "YOUR_PROJECT_ID",
// ... other config
});
// Get auth instance AFTER initializing app
const auth = getAuth(app);
// NOW you can use auth methods
import { signInWithEmailAndPassword } from 'firebase/auth';
signInWithEmailAndPassword(auth, email, password);If you try to use auth methods before initializeApp(), you'll get invalid argument errors.
Firebase authentication method names are specific. Common mistakes:
// WRONG: Not a real Firebase method
signInWithPhone(auth, number); // Should be signInWithPhoneNumber
auth.loginWithEmail(email, pwd); // Should be signInWithEmailAndPassword
// WRONG: Missing required parameters
createUserWithEmailAndPassword(auth); // Missing email and password
// CORRECT
signInWithPhoneNumber(phoneNumber, appVerifier);
signInWithEmailAndPassword(auth, email, password);
createUserWithEmailAndPassword(auth, email, password);Verify the exact method name in the [Firebase Authentication API Reference](https://firebase.google.com/docs/reference/js/auth).
Advanced notes
Firebase SDK Versions: Firebase v9+ is the modern modular SDK and is recommended for new projects. If you're maintaining legacy code with v8 (compat), be aware that mixing syntaxes will cause parameter validation errors.
TypeScript Support: If using TypeScript, enable strict mode and let the type system catch parameter mismatches at compile time:
import { Auth, signInWithEmailAndPassword } from 'firebase/auth';
async function login(auth: Auth, email: string, password: string) {
// TypeScript will error if parameters are in wrong order or wrong type
const result = await signInWithEmailAndPassword(auth, email, password);
return result.user;
}React Native: If using React Native Firebase (rnfirebase), the syntax is different:
import auth from '@react-native-firebase/auth';
auth()
.signInWithEmailAndPassword(email, password)
.catch((error) => console.error(error.code));Always check your specific Firebase library documentation.
Frequently asked questions
- What does "auth/invalid-argument: Invalid parameter passed to method" mean?
- Firebase Authentication throws the "invalid-argument: Invalid parameter passed to method" error when one or more parameters provided to an auth method don't meet the method's requirements. This is a validation error that occurs before Firebase attempts authentication. The error typically indicates that: 1.
- How do I fix "auth/invalid-argument: Invalid parameter passed to method"?
- This error occurs when you pass invalid parameters to Firebase Authentication methods. Common causes include empty strings, null values, wrong parameter types, or incorrect method syntax. Most fixes involve validating inputs before passing them to Firebase functions.
- What causes "auth/invalid-argument: Invalid parameter passed to method"?
- Passing empty strings or null/undefined values to required parameters like email or password Using Firebase v9+ modular SDK syntax with v8 compat code or vice versa Incorrect parameter order (e.g., passing password before email)
- Is the "auth/invalid-argument: Invalid parameter passed to method" error serious?
- It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚Firebase Official Documentation
- 📖Firebase Admin Authentication API Errors(Official Docs)
- 📖Firebase JavaScript SDK - Error Reference(Official Docs)
- 🐙