I am new and have followed the docs to get an access token using the doc generated code with all the right app creds etc as screenshots below but keep getting a 401 error, do I need to config the users in anyway?this is driving me crazy , can any Auth0 staff please put me on the right path please?
Hello @jamie.warnock
I would recommend using the following code:
`var request = require(“request”);
var options = { method: ‘POST’,
url: ‘https://YOUR_DOMAIN/oauth/token’,
headers: { ‘content-type’: ‘application/x-www-form-urlencoded’ },
form:
{ client_id: ‘YOUR_CLIENT_ID’,
client_secret: ‘YOUR_CLIENT_SECRET’,
audience: ‘API_IDENTIFIER’,
grant_type: ‘client_credentials’ }
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});`
Can you provide the complete response you are getting?
Thanks!
Hello Karen,
Thanks for your reply, but I have tried that code from your docs and because it is a clientside NuxtJS app could not use the request library as it is server side node.js module, but I hoped axios being clientside would work to make the HTTP request, also I have been advised by one of your colleagues I need to setup a proxy API to redirect the request from Auth0 to, bit beyond me but looking into it!
Thanks,
Jamie
Hi Jamie, have you figured out this issue ? I’ve followed the code on this page for Node.js - Call Your API Using the Client Credentials Flow
and I also get a 401 error.
Hi there @weborders,
Have you experienced any success leveraging Karen’s code example above? Thanks in advance!
Hi James. I tried Karen’s code but with the same 401 result.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.