Access token not exists in token/oauth

Hi all!
I’m new at oauth and facing a problem than can’t figure out how to fix. In my production environment, i’m getting “Access token not exists” error when try a POST to oauth/token endpoint.

My source code:

var rp = require('request-promise');
var options = { method: 'POST',
  url: 'https://playmojo.eu.auth0.com/oauth/token',
  headers: { 'content-type': 'application/json' },
   body: {
    client_id : <CLIENT_ID>, 
    client_secret : <CLIENT_SECRET>, 
    audience: 'https://playmojo.eu.auth0.com/api/v2/', 
    grant_type : 'client_credentials'
  }
 };
try {
  const response = await rp(options);
  console.log('getToken OK: ' + response);
  return response;
 }  catch (error) {
  console.log('getToken error: ' + error);
  return {error:true, message:error};
}

Any help will be appreciated.
Thanks in advance,
Antonio.

Per the request-promise README, you need to set json: true in the options:

var options = { method: 'POST',
  url: 'https://playmojo.eu.auth0.com/oauth/token',
  headers: { 'content-type': 'application/json' },
   body: {
    client_id : <CLIENT_ID>, 
    client_secret : <CLIENT_SECRET>, 
    audience: 'https://playmojo.eu.auth0.com/api/v2/', 
    grant_type : 'client_credentials'
  },
  json: true
 };

Hi Richard. I had to create a new account, don’t what happened but couldn’t log in with my original one. I tried what you suggested but still having the same issue. It’s really weird, since in development envirionment works fine. Perhaps any configuration mistake? What else could i try?

Best regards,
Antonio

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