由网友(亡心忘)分享简介:在我的Express应用程序中,我必须获取Auth0的访问令牌。在文档中,他们有一个纯Node JS的示例,其中包含一个请求:var request = require("request");var options = { method: 'POST',url: 'https://XXX.eu.auth0.com/oa...在我的Express应用程序中,我必须获取Auth0的访问令牌。在文档中,他们有一个纯Node JS的示例,其中包含一个请求:
![Access Token 访问令牌 如何获取](https://p.xsw88.cn/allimgs/daicuo/20230903/3648.png)
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);
});
但当我试图以下一种方式做同样的事情时:
app.post('/token', function(options, res) {
return res.json()
});
我收到"未授权错误:未找到授权令牌"。
![Access Token 访问令牌 如何获取](https://p.xsw88.cn/allimgs/daicuo/20230903/3648.png)
我如何才能正确地执行此操作?
推荐答案
是否确实已在应用程序中启用CLIENT_Credentials授权类型? 转到应用程序/高级/授权类型并启用CLIENT_Credentials
See picture here
相关推荐
最新文章