MultiFactorError interface
Stay organized with collections
Save and categorize content based on your preferences.
The error thrown when the user needs to provide a second factor to sign in successfully.
The error code for this error is auth/multi-factor-auth-required
.
Signature:
export interface MultiFactorError extends AuthError
Extends: AuthError
Properties
MultiFactorError.customData
Details about the MultiFactorError.
Signature:
readonly customData: AuthError['customData'] & {
readonly operationType: (typeof OperationTypeMap)[keyof typeof OperationTypeMap];
};
Example
let resolver;
let multiFactorHints;
signInWithEmailAndPassword(auth, email, password)
.then((result) => {
// User signed in. No 2nd factor challenge is needed.
})
.catch((error) => {
if (error.code == 'auth/multi-factor-auth-required') {
resolver = getMultiFactorResolver(auth, error);
multiFactorHints = resolver.hints;
} else {
// Handle other errors.
}
});
// Obtain a multiFactorAssertion by verifying the second factor.
const userCredential = await resolver.resolveSignIn(multiFactorAssertion);
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 2023-04-27 UTC.
[null,null,["Last updated 2023-04-27 UTC."],[],[],null,["# MultiFactorError interface\n\nThe error thrown when the user needs to provide a second factor to sign in successfully.\n\nThe error code for this error is `auth/multi-factor-auth-required`.\n\n**Signature:** \n\n export interface MultiFactorError extends AuthError \n\n**Extends:** [AuthError](./auth.autherror.md#autherror_interface)\n\nProperties\n----------\n\n| Property | Type | Description |\n|---------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------|\n| [customData](./auth.multifactorerror.md#multifactorerrorcustomdata) | [AuthError](./auth.autherror.md#autherror_interface)\\['customData'\\] \\& { readonly operationType: (typeof [OperationTypeMap](./auth.md#operationtype))\\[keyof typeof [OperationTypeMap](./auth.md#operationtype)\\]; } | Details about the MultiFactorError. |\n\nMultiFactorError.customData\n---------------------------\n\nDetails about the MultiFactorError.\n\n**Signature:** \n\n readonly customData: AuthError['customData'] & {\n readonly operationType: (typeof OperationTypeMap)[keyof typeof OperationTypeMap];\n };\n\n### Example\n\n let resolver;\n let multiFactorHints;\n\n signInWithEmailAndPassword(auth, email, password)\n .then((result) =\u003e {\n // User signed in. No 2nd factor challenge is needed.\n })\n .catch((error) =\u003e {\n if (error.code == 'auth/multi-factor-auth-required') {\n resolver = getMultiFactorResolver(auth, error);\n multiFactorHints = resolver.hints;\n } else {\n // Handle other errors.\n }\n });\n\n // Obtain a multiFactorAssertion by verifying the second factor.\n\n const userCredential = await resolver.resolveSignIn(multiFactorAssertion);"]]