Forum Discussion
Azure B2C password reset using username
Way late, but thought I should leave this here for anyone else encountering this issue. The problem was caused by a missing authentication method for the user (as renevanmiloliver also discovered).
In my case, I was creating the user account using the Graph API, with "userName" sign-in type, which resulted in the same behaviour described by OP. Eventually, I compared a user created that way with a user I created using a Sign Up/Sign In flow, and discovered that the user created by the flow had an email address listed under "Authentication methods" in the Azure portal. After some fiddling around with the Graph API, I found that I could simply add the same thing to my Graph-created users. My code looks like this (not ideal, but the GraphServiceClient doesn't appear to support doing this the same way it supports creating a user):
Microsoft.Graph.User userResult = await graphServiceClient.Users.Request().AddAsync(user);
string url = graphServiceClient.Users[userResult.Id].Authentication.AppendSegmentToRequestUrl("emailMethods");
HttpRequestMessage message = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri(url),
Content = new StringContent($"{{\"emailAddress\":\"{profile.Email}\"}}", Encoding.UTF8, "application/json")
};
_ = await graphServiceClient.HttpProvider.SendAsync(message);
Hope this helps someone else.