Suddenly my application is no longer able to update phoneAuthenticationMethod when it's created on B2C.
UPDATE STEPS TO REPRODUCE ISSUE:
Enable MFA using Custom Policy starter pack from MS(https://github.com/Azure-Samples/active-directory-b2c-custom-policy-starterpack/tree/main/SocialAndLocalAccountsWithMfa)
Create user in B2C and add MFA(SMS) to it using custom policy above
Get User MFA using Graph API to confirm that MFA was created
The error occurs if you try to update the phone method when there is no existing mobile number added to that user as authentication method.
I have one user with phone authentication method added in office
phoneType as below:
When I tried to update that phone method as mobile
phoneType and Id as 3179e48a-750b-4051-897c-87b9720928f7, I too got same error like this:
PATCH https://graph.microsoft.com/v1.0/users/userId/authentication/phoneMethods/3179e48a-750b-4051-897c-87b9720928f7
{
"phoneNumber": "+1 2065555554",
"phoneType": "mobile"
}
Response:
As mentioned in this MS Document,
The value of
phoneMethodId
changes depending on phoneType you want to update:
b6332ec1-7057-4abe-9331-3d72feddfe41
to update thealternateMobile
phoneType.e37fc753-ff3b-4958-9484-eaa9425c82bc
to update theoffice
phoneType.3179e48a-750b-4051-897c-87b9720928f7
to update themobile
phoneType.
In your case, initially fetch the list of phone methods added to user with below API call:
GET https://graph.microsoft.com/v1.0/users/userId/authentication/phoneMethods/
Response:
If mobile
phoneType is not present in response, make use of POST call to add it as authentication method like below:
POST https://graph.microsoft.com/v1.0/users/userId/authentication/phoneMethods/
{
"phoneNumber": "+1 2065555554",
"phoneType": "mobile"
}
Response:
You can now update this using PATCH call as phone method of mobile
phoneType is existing now:
PATCH https://graph.microsoft.com/v1.0/users/userId/authentication/phoneMethods/3179e48a-750b-4051-897c-87b9720928f7
{
"phoneNumber": "+1 2055555555",
"phoneType": "mobile"
}
Response:
To confirm that, I checked the same in Portal where phone method of mobile
phoneType update successfully: