For someone else who comes across this post and might find it useful ... There is nothing wrong with my code. I made a mistake when requesting an access code of type client_credentials instead of a password access code (#facepalms). FYI I use urlencoded message, therefore, use querystring .. So, for those who can look for some sample code .. here is my full request
Many thanks to @swapnil for trying to help me debug this.
const data = { grant_type: USER_GRANT_TYPE, client_id: CLIENT_ID, client_secret: CLIENT_SECRET, scope: SCOPE_INT, username: DEMO_EMAIL, password: DEMO_PASSWORD }; axios.post(TOKEN_URL, Querystring.stringify(data)) .then(response => { console.log(response.data); USER_TOKEN = response.data.access_token; console.log('userresponse ' + response.data.access_token); }) .catch((error) => { console.log('error ' + error); }); const AuthStr = 'Bearer '.concat(USER_TOKEN); axios.get(URL, { headers: { Authorization: AuthStr } }) .then(response => {
source share