I am triying to log in users using asp.net core api, and I am getting this error:
{"error":"access_denied","error_description":"Cannot read property 'AuthRoles' of undefined"}
I am triying to login the user this way:
try
{
// Obtain access token for Auth0 Management API
var accessToken = await GetAuth0ApiAccessTokenAsync();
// Initialize Auth0 Management API client
var managementApiClient = new ManagementApiClient(accessToken, auth0Options.Domain);
// Create user request
var userCreateRequest = new UserCreateRequest
{
Email = user.Email,
Password = user.Password,
Connection = auth0Options.Connection,
VerifyEmail = false,
UserMetadata = new Dictionary<string, string>()
{
{ "given_name", user.FirstName },
{ "family_name", user.LastName },
{ "phone_number", user.PhoneNumber },
}
};
// Create user on Auth0
var newUser = await managementApiClient.Users.CreateAsync(userCreateRequest);
// Return the created user's ID
return newUser.UserId;
}
catch (Exception ex)
{
// Handle exceptions and log errors
//Log.Error(âAn unexpected error occurred while creating user on Auth0: {userEmail}. Exception message: {ExceptionMessage}â, user.Email, ex.Message);
throw new Exception("An unexpected error occurred: " + ex.Message, ex);
}