Exception of type 'Auth0.Core.Exceptions.ApiException' was thrown

I’m trying to implement password change functionality in .net core by using AuthenticationApiClient. At first I send magic link to email, then after clicking on it new page opens where user can type new password and click Save. After clicking Save button I’m sending ChangePasswordRequest from code-behind. The problem is that that ChangePasswordAsync method always returns “Exception of type ‘Auth0.Core.Exceptions.ApiException’ was thrown.” exception. Can you let me know how to get more detailed information about exception? what is the exact issue with request and how to process it?

Thanks

Hey there @ybrutyan!

I don’t have ASP.NET experience but if you provide me with more context I’ll be able to dig into it and provide you with a solution. If you can tell me if you’re using one of our samples/ quickstarts or you’re implementing everything yourself hitting right endpoints and using appropriate SDKs of ours?

Thank you!

Hi @konrad.sopala !

I’m using Auth0.AuthenticationApi nuget package for .net core. It provides AuthenticationApiClient class which I’m using for Login/Signup/Paswordless/ChangePassword requests. Only ChangePassword throws exception.
The process is follow user clicks on ‘Forgot Password’ link, provides email and receives magic link for resetting password. Sample code:

AuthenticationApiClient client = new AuthenticationApiClient(new Uri($“https://{Auth.Domain}/”));
// Preparing request
var request = new PasswordlessEmailRequest()
{
ClientId = {ClientId},
Email = {Email},
Type = PasswordlessEmailRequestType.Link
};
request.AuthenticationParameters.Add(“scope”, “openid profile”);

// Calling for password recovery by email
await client.StartPasswordlessEmailFlowAsync(request);

Then after clicking on link he goes to the new page where fills new Password and click ‘Change Password’. Here is the sample code for it:

AuthenticationApiClient client = new AuthenticationApiClient(new Uri($“https://{Auth.Domain}/”));
// Preparing request
var request = new ChangePasswordRequest()
{
ClientId = ‘ClientId’,
Connection = “email”,
Email = {Email},
Password = {Password}
};

// Calling for password change
var response = await client.ChangePasswordAsync(request);

In the last call I’m getting exception. Please let know if you need more info.

Thank you!

Thank you a lot for that context! Will let you know if I need anything more!

I found that you will see this message when logging or throwing the ApiException on it’s own. The detailed error message is in the ApiException.ApiError.Error property.

I figured I’d post my findings here (even though this is an old thread) because this is where my Google search led me. Hope you’ve solved your problem by now as well.

1 Like