I am using Microsoft Graph beta and trying to reset password for the user..
It is giving me following error
"Exception of type 'Microsoft.Graph.Beta.Models.ODataErrors.ODataError' was thrown.:::: at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.ThrowFailedResponse(HttpResponseMessage response, Dictionary2 errorMapping) at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory1 factory, IResponseHandler responseHandler, Dictionary`2 errorMapping, CancellationToken cancellationToken)"
My Code
GraphServiceClient _graphClient = GraphHelper.GetAuthenticatedGraphClient(config, credentials);
try
{
await _graphClient.Users[userId].ChangePassword.PostAsync(new Microsoft.Graph.Beta.Users.Item.ChangePassword.ChangePasswordPostRequestBody
{
CurrentPassword = "Password1",
NewPassword = "Password2"
});
}
catch(Exception ex)
{
Console.WriteLine(ex.Message + "::::" + ex.StackTrace);
}
public static GraphServiceClient GetAuthenticatedGraphClient(IConfigurationRoot config, B2CCredentials credentials)
{
var scopes = new[] { "https://graph.microsoft.com/.default" };
var options = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};
var clientSecretCredential = new ClientSecretCredential(
credentials.B2CTenantId, credentials.ClientId, credentials.ClientSecret, options);
var graphClient = new GraphServiceClient(clientSecretCredential, scopes);
return graphClient;
}