I am getting 400 after sending the request below to my b2c tenant. see below more details:
Microsoft.Graph.ServiceException: Code: methodNotAllowed
Message: The method is not supported for this URL.
I need to reset the user password, so I am following what is described here: https://docs.microsoft.com/en-us/graph/api/passwordauthenticationmethod-resetpassword?view=graph-rest-beta&tabs=csharp
public async Task<string> ResetPassword(string userId)
{
var newPassword = Helpers.PasswordHelper.GenerateNewPassword(4, 8, 4);
var result = await graphClient
.Users[userId]
.Authentication.PasswordMethods["{passwordAuthenticationMethod-id}"]
.ResetPassword(newPassword, null)
.Request()
.PostAsync();
return result.NewPassword;
}
and here is the packages I am using
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Graph.Auth" Version="1.0.0-preview.4" />
<PackageReference Include="Microsoft.Graph.Beta" Version="0.39.0-preview" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.13.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
</ItemGroup>
</Project>