Endpoint `/api/v2/users-by-email` returning Bad Request

I am using a token with grant_type client_credentials to GET a user using the endpoint api/v2/users-by-email, everything looks right and this is not the first time I use this endpoint with clientID, but the API is returning a Bad Request:

{“statusCode”:400,“error”:“Bad Request”,“message”:“Bad HTTP authentication header format”,“errorCode”:“Bearer”}

I am following this doc about getting the token: Get Management API Access Tokens for Production
And following this doc about the endpoint: Retrieve Users with Get Users by Email Endpoint

What else should I do to find the problem?

Hi @guilherme.fonseca,

Welcome to the Auth0 Community!

The two pieces of documentation you found are correct for getting an API access token to use with the Management API.

In this case, the error is pointing at your request header parameters, specifically about your bearer token.

I was able to reproduce this issue by not providing a bearer token in my request. See below.

To use the Management API, you will need to check and make sure to pass the access token with the request as an authorization header.

After doing so, you can use the Management API.

Please let me know how this goes for you.

Thanks.

Hi @rueben.tiow! Thanks for your response!

I doubled check my requests and I am sure that the bearer token is provided. Tested either with curl and Postman, both with the same error. The latter I’ve tested using the header and the authorization tab.

Is there something I can look into the token to be sure that it is correct?

It is something like this, as the documentation examples:
{
“access_token”: “eyJ…Ggg”,
“expires_in”: 86400,
“scope”: “read:clients create:clients read:client_keys”,
“token_type”: “Bearer”
}

1 Like

Hi @rueben.tiow,

I’ve found the problem, you were correct!

I was using the token in the wrong way.

Thanks for your support, it has helped me.

1 Like

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