Baby step for api create user. Exception Not Found

I’m starting to use Auth0 in an ASP.NET MVC application (Owin)

I am not understanding how to use the API to create my users.

My steps:

1 - Create “Regular Web Application”

image

2 - APIs menu

Auth0 Management API created automatically
In the “Machine to Machine Applications” tab I selected my web application and assign the necessary permissions

And my source code is:

        var authClient = new AuthenticationApiClient(new Uri(Domain));
        var response = await authClient.GetTokenAsync(new ClientCredentialsTokenRequest
        {
            ClientId = ClientId,
            ClientSecret = ClientSecret,
            Audience = Audience
        });

> //AccessToken is ok
> var managerClient = new ManagementApiClient(response.AccessToken, new Uri(Domain));
> var users = await managerClient.Users.GetUsersByEmailAsync("my@email.com"); //user exists with email

Exception message: “Not found.”

My Settings:

Domain: https://MY_TENANT.auth0.com/
Audience: https://MY_TENANT.auth0.com/api/v2/
ClientId: MY_REGULAR_APPLICATION_CLIENTID
ClientSecret: MY_REGULAR_APPLICATION_CLIENTSECRET

Hi

In ManagementApiClient constructor the second parameter is audience

Solution:

new ManagementApiClient(response.AccessToken, new Uri(Audience));

:smiley:

Here my tutorial to beginners :sweat_smile:

Regards

1 Like

Glad you figured this out and thanks for sharing with the rest of community!