401 "Bad audience" error when resending email verification

Hi,

I have a .NET 8 Blazor WASM app and .NET API which I have successfully enabled Auth0 for, however I am trying to implement an endpoint to resend verification email but I’m receiving the following error when calling https://login.auth0.com/api/v2/jobs/verification-email:

{
  "statusCode": 401,
  "error": "Unauthorized",
  "message": "Bad audience: https://{myName}.uk.auth0.com/api/v2/"
}

I have created a M2M app that has access to the management API and has the correct scope to be able to call this endpoint. I am able to successfully retrieve an access token using the following params:

var requestContent = new FormUrlEncodedContent(new Dictionary<string, string>
{
    { "Content-Type", "application/x-www-form-urlencoded" },
    { "grant_type", "client_credentials" },
    { "client_id", settings.ClientId },
    { "client_secret", settings.ClientSecret },
    { "audience", "https://{myName}.uk.auth0.com/api/v2/" }
});

 var response = await httpClient.PostAsync(TokenEndpoint, requestContent, cancellationToken);

Any help with this would be greatly appreciated.

For anyone else who comes across this…

After days of debugging it turns out the documentation is simply out of date and

https://login.auth0.com/api/v2/jobs/verification-email

should actually be

https://{myName}.{countryCode}.auth0.com/api/v2/jobs/verification-email.

:man_facepalming:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.