Microsoft Graph API, deleting authentication method "Microsoft Authenticator" Returns 400 Error

Angel Fontalvo Avila 20 Reputation points
2023-07-26T15:28:05.0133333+00:00

Hi,

I'm attempting to delete a user's Microsoft Authenticator Authentication Method (#microsoft.graph.microsoftAuthenticatorAuthenticationMethod) from the user's list of authentication methods. However, I keep receiving the following error:

Status Code: 400, Bad Request

Error Message: Cannot delete default method with other methods configured. Please change default method before deletion.

Here is my code snippet:

async deleteUserAuthenticationMethod(email, authId, accessToken) {
    const query = `/users/${email}/authentication/microsoftAuthenticatorMethods/${authId}`

    await azure.graph.delete(query, {
        headers: {
            'Authorization': 'Bearer ' + accessToken
        }
    });

    return 'Authentication method deleted successfully';              
}

Here are all of the available authentication methods the user has set:

  • #microsoft.graph.passwordAuthenticationMethod
  • #microsoft.graph.microsoftAuthenticatorAuthenticationMethod

Please advise.

Thank you

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,162 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. CarlZhao-MSFT 39,181 Reputation points
    2023-07-27T09:56:18.71+00:00

    Hi @Angel Fontalvo

    As the error message indicates, the default method with other methods configured cannot be deleted. This error will be thrown if you are trying to remove the user's default authentication method.

    You can first list all authentication methods for a user, including the default method, and then change the default method to the target method to delete other authentication methods except the default method.

    Refer to similar thread: https://github.com/microsoftgraph/microsoft-graph-docs/issues/14470.

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    0 comments No comments