# error: 'unsupported\_grant\_type', (durng token exchange)

**URL:** <https://forum.asana.com/t/error-unsupported-grant-type-durng-token-exchange/93009>\
**Category:** API & Developers\
**Created:** [28 August 2020 16:51 UTC](https://forum.asana.com/t/error-unsupported-grant-type-durng-token-exchange/93009 "2020-08-28T16:51:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_DeSilva](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/sean_desilva/32/60162_2.png) [@Sean\_DeSilva](https://forum.asana.com/u/Sean_DeSilva)\
**Post date:** [28 August 2020 16:51 UTC](https://forum.asana.com/t/error-unsupported-grant-type-durng-token-exchange/93009/1 "2020-08-28T16:51:41Z")

</div>

I am attempting to do token exchange with an auth code, from an Express.js API. I am getting back an error object:

```auto
error: 'unsupported_grant_type',
  error_description: 'The supported grant types are `authorization_code` and `refresh_token`.'

```

This is the object I send as the post request body (stringified). Is there a mistake or omission somewhere?

```auto
tokenRequestBody {
  grant_type: 'authorization_code',
  client_id: '11885REMOVED',
  client_secret: 'b2d0b11a1REMOVED',
  redirect_uri: 'https://asanarepeater.ngrok.io/authCode',
  code: '1/111920289783REMOVED'
}

```

Here is the surrounding context:

```auto
router.get('/authCode', async (req: Request, res: Response) => {
  const tokenExchangeEndpoint = 'https://app.asana.com/-/oauth_token';

  const tokenRequestBody: IAuthCodeRequest = {
    grant_type: 'authorization_code',
    client_id: process.env.ASANA_CLIENT_ID!,
    client_secret: process.env.ASANA_CLIENT_SECRET!,
    redirect_uri: process.env.ASANA_HTTPS_REDIRECT_URL!,
    code: req.query.code as string,
  };

  // the object shown above
  console.log('tokenRequestBody', tokenRequestBody);

  try {
    const response = await fetch(tokenExchangeEndpoint, {
      method: 'post',
      // mode: 'cors',
      headers: {
        'content-type': 'application/json',
      },
      body: JSON.stringify(tokenRequestBody),
    });

    const tokenObject: ITokenResponseBody = await response.json();

    // the error object prints
    console.log('tokenObject', tokenObject);

```

---

<div class="post-metadata">

**Author:** ![Nik4](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/nik4/32/89315_2.png) [@Nik4](https://forum.asana.com/u/Nik4)\
**Post date:** [13 November 2021 22:10 UTC](https://forum.asana.com/t/error-unsupported-grant-type-durng-token-exchange/93009/2 "2021-11-13T22:10:06Z")

</div>

You need set headers content-type as ‘application/x-www-form-urlencoded’ format

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/system/32/276370_2.png) [@system](https://forum.asana.com/u/system)\
**Post date:** [30 May 2025 19:04 UTC](https://forum.asana.com/t/error-unsupported-grant-type-durng-token-exchange/93009/3 "2025-05-30T19:04:58Z")

</div>

Closed on 30 May 2025 19:04 UTC


