在我的Express应用中,我必须获取Auth0的访问令牌。在文档中,他们有一个带有请求的纯Node JS的示例:
Main()
但是当我尝试以另一种方式做同样的事情时:
var request = require("request");
var options = { method: 'POST',
url: 'https://XXX.eu.auth0.com/oauth/token',
headers: { 'content-type': 'application/json' },
body: '{"client_id":"XXX","client_secret":"XXX","audience":"http://localhost:3001/","grant_type":"client_credentials"}' };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
我收到“ UnauthorizedError:未找到授权令牌”。
我该怎么做?
答案 0 :(得分:0)
您确定已在应用中启用了client_credentials授予类型吗? 转到应用程序/高级/授权类型并启用client_credentials