# Unable to get a token on behalf of a user. "Client must be a Custom API Client with resource\_server\_id"

**URL:** <https://community.auth0.com/t/unable-to-get-a-token-on-behalf-of-a-user-client-must-be-a-custom-api-client-with-resource-server-id/200896>\
**Category:** Get Help\
**Tags:** oauth-2-0, protocols\
**Created:** [June 16, 2026, 6:32pm UTC](https://community.auth0.com/t/unable-to-get-a-token-on-behalf-of-a-user-client-must-be-a-custom-api-client-with-resource-server-id/200896 "2026-06-16T18:32:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dave.natalie](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dave.natalie/32/60163_2.png) [@dave.natalie](https://community.auth0.com/u/dave.natalie)\
**Post date:** [June 16, 2026, 6:32pm UTC](https://community.auth0.com/t/unable-to-get-a-token-on-behalf-of-a-user-client-must-be-a-custom-api-client-with-resource-server-id/200896/1 "2026-06-16T18:32:52Z")

</div>

I am following the documentation here.

> **[On-Behalf-Of Token Exchange - Auth0 Docs](https://auth0.com/docs/secure/call-apis-on-users-behalf/on-behalf-of-token-exchange#curl)**
>
> Was this page helpful? | Learn how to use the On-Behalf-Of (OBO) token exchange to enable middle-tier services to preserve user identity and permissions when calling downstream APIs.

When I send the token request, I get the following response.

```auto
{
    "error": "invalid_request",
    "error_description": "Client must be a Custom API Client with resource_server_id"

}

```

I am not sure what this error means.

My request looks like this.

POST `https://mydomain.com/oauth/token`

```auto
{
    "client_id": "{clientId}",
    "client_secret": "{clientSecret}",
    "subject_token": "eyJ…", //Incoming bearer token
    "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
    "subject_token_type": "urn:ietf:params:oauth:token-type:access_token",
    "requested_token_type": "urn:ietf:params:oauth:token-type:access_token",
    "audience": "https://{target api identifier}"
  }

```

My client is registered as a Machine to Machine application. I have client\_credentials enabled as a grant type, but I don’t see a way in the management portal to enable the token-exchange grant type.

Is there something else I need to do to on-behalf-of work?

---

<div class="post-metadata">

**Author:** ![gerald.czifra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gerald.czifra/32/75301_2.png) [@gerald.czifra](https://community.auth0.com/u/gerald.czifra)\
**Post date:** [June 17, 2026, 5:35pm UTC](https://community.auth0.com/t/unable-to-get-a-token-on-behalf-of-a-user-client-must-be-a-custom-api-client-with-resource-server-id/200896/3 "2026-06-17T17:35:28Z")

</div>

Hi @dave.natalie

Welcome to the Auth0 Community!

I understand that you are configuring On-Behalf-Of Token Exchange and are encountering the " Client must be a Custom API Client with resource\_server\_id " error message.

The usual culprit in such cases would be the prerequisites of creating the Custom API client, creating the grant type and then configuring the On-Behalf-Of ( OBO ) Token Exchange before testing. I recommend double-checking these steps from the [On-Behalf-Of Token Exchange](https://auth0.com/docs/secure/call-apis-on-users-behalf/on-behalf-of-token-exchange#create-custom-api-client) documentation that you shared, as it can happen that changes are not saved or immediately reflected if testing right after setting everything up. In particular, ensure that you have made the `Patch` request to the [`/api/v2/clients/{clientId}`](https://auth0.com/docs/api/management/v2/clients/patch-clients-by-id) endpoint with the following request body, in order to add the token exchange grant to your client’s `grant_types` array:

```auto
curl --location --request PATCH 'https://{yourDomain}/api/v2/clients/{clientId}' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_MANAGEMENT_API_TOKEN' \
  --data '{
    "token_exchange": {
      "allow_any_profile_of_type": ["on_behalf_of_token_exchange"]
    }
  }'

```

In addition, the following details are worth to be noted as well:

- please ensure the `client_id` and `client_secret` in your POST request belong to the **Custom API Client** that represents your backend API (the audience of the incoming `subject_token` ), not a separate M2M app;

- Use the Auth0 Management API to `PATCH` that specific client and explicitly append `urn:ietf:params:oauth:grant-type:token-exchange` to its permitted `grant_types`

After making the `Patch` request, perform the OBO token exchange once more and let us know if you are still getting the same error message, or if anything changed.

Best regards,  
Gerald

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [July 1, 2026, 5:35pm UTC](https://community.auth0.com/t/unable-to-get-a-token-on-behalf-of-a-user-client-must-be-a-custom-api-client-with-resource-server-id/200896/4 "2026-07-01T17:35:33Z")

</div>

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