Auth0 Home Blog Docs

Access Token after getting auth code

I am getting auth code by hitting below URL.

https://YOUR_AUTH0_DOMAIN/authorize?
    audience=YOUR_API_AUDIENCE&
    scope=YOUR_SCOPE&
    response_type=code&
    client_id=YOUR_CLIENT_ID&
    redirect_uri=https://YOUR_APP/callback&
    state=YOUR_OPAQUE_VALUE

When I try to get access token using code that I got in previous step, it says access denied. I am using below URL to get access token.

options = { method: 'POST',
  url: 'https://YOUR_AUTH0_DOMAIN/oauth/token',
  headers: { 'content-type': 'application/json' },
  body: 
   { grant_type: 'authorization_code',
     client_id: 'YOUR_CLIENT_ID',
     client_secret: 'YOUR_CLIENT_SECRET',
     code: 'YOUR_AUTHORIZATION_CODE',
     redirect_uri: 'https://YOUR_APP/callback' },
  json: true };

Any help?

Is this a server-side request to the /oauth/token endpoint? Can you post the exact response that you get, including the status code?

Also, double check all the parameters to make sure they are correct.