title: Discord OAuth returns missing "code in request
body: <p>I'm trying to use a simple example to fetch an access token from the Discord API. I have the authorization code, but I'm struggling on exchanging it for the access token.</p>
  <p>My code so far:</p>
  <pre><code>const code = **my authorization code**;
  const CLIENT_ID = **my client id**;
  const CLIENT_SECRET = **my client secret**;
  const creds = btoa(`${CLIENT_ID}:${CLIENT_SECRET}`);
  fetch(`https://discordapp.com/api/oauth2/token?grant_type=authorization_code&amp;code=${code}&amp;redirect_uri=${redirect}`,
    {
      method: &quot;POST&quot;,
      headers: {
        Authorization: `Basic ${creds}`,
    },
  })
    .then((res) =&gt; res.json())
    .then((body) =&gt; console.log(body));
  </code></pre>
  <p>However, when I run this code, I get the following error:</p>
  <pre><code>{
     error: 'invalid_request',
     error_description: 'Missing &quot;code&quot; in request.'
  }
  </code></pre>