title: atlassian cloud oauth 2.0, Error 403 on POST request to get token
body: <p>I am going to integrate my angular app with Jira cloud. To authenticate users, Atlassian uses OAuth 2.0 to let the external apps access product API on users' behalf. I followed the instruction from <a href="https://developer.atlassian.com/cloud/jira/platform/oauth-2-authorization-code-grants-3lo-for-apps/" rel="nofollow noreferrer">this page</a></p>
  <ol>
  <li>Direct the user to the authorization URL to get an authorization code</li>
  <li><strong>Exchange the authorization code for an access token</strong></li>
  <li>Authorize any calls to the product APIs using the access token</li>
  <li>Check site access for the app</li>
  </ol>
  <p>I successfully pass the first step. But at the second step, my POST request to get the token gets failed.
  This is my request data</p>
  <pre><code>    {
      &quot;grant_type&quot;:&quot;authorization_code&quot;,
      &quot;client_id&quot;:&quot;xxx&quot;, 
      &quot;client_secret&quot;:&quot;xxx&quot;,
      &quot;code&quot;:&quot;xxx&quot;, // I receive this code from callback url from atlassian login page
      &quot;redirect_uri&quot;:&quot;http://localhost:4200/&quot;}
  </code></pre>
  <p>This is the header:</p>
  <pre><code>{'Content-Type': 'application/json'}
  </code></pre>
  <p>And this is what I receive:</p>
  <pre><code>{&quot;error&quot;:&quot;invalid_grant&quot;,&quot;error_description&quot;:&quot;Invalid authorization code&quot;}
  </code></pre>
  <p>this is the request code written in Angular 10:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>this.http
          .post(
            'https://auth.atlassian.com/oauth/token', {
              grant_type: 'authorization_code',
              client_id: environment.oauth.clientID,
              client_secret: environment.oauth.secret,
              code: codeStr,
              redirect_uri: environment.oauth.redirect_uri
            }, {
              headers: exchangeAuthCodeHeader,
              responseType: 'json'}
          ).subscribe((data) =&gt; console.log(data), (error) =&gt; console.log(error));</code></pre>
  </div>
  </div>
  </p>
  <p>I have been stuck in this error for a couple of days :(
  Any idea would be a great help.</p>