我已经下载了Node/Hapi快速入门网站:https://auth0.com/docs/quickstart/backend/hapi,并预先填写了数据。
我能够运行节点服务器并访问/public端点。当我尝试访问/private端点时(通过POSTMAN),我得到以下错误:
{
"statusCode": 401,
"error": "Unauthorized",
"message": "Missing authentication"
}为了获得访问令牌,我使用以下有效负载向https://<My Account>.auth0.com/oauth/ro发送请求:
{
"client_id": "<My Client ID>",
"username": "<My Username>",
"password": "<My Password>",
"connection": "Username-Password-Authentication",
"grant_type": "password",
"scope": "openid name email"
}返回包含我的访问令牌的响应:
{
"id_token": <Id Token>,
"access_token": <Access Token>,
"token_type": "bearer"
}现在,我尝试使用我的访问令牌访问/private端点,以传递授权头,如下所示:
GET /private HTTP/1.1
Host: <My Machine Name>:8000
Authorization: Bearer <Access Token>
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 87dd4307-2a1c-b36e-0377-129cf60b676d返回以下错误:
{
"statusCode": 400,
"error": "Bad Request",
"message": "Bad HTTP authentication header format"
}我尝试了很多事情,但无法超越这一点。任何帮助都将不胜感激。
环境规范:
谢谢你,吉纳罗
发布于 2016-10-10 08:03:59
假设您正在执行问题中描述的事情,问题是在调用/private端点而不是access_token时,需要传递接收到的id_token。
在快速启动的第4点中提到了这一点:
现在,您可以通过在请求中提供一个有效的JWT id_token来对您的安全API提出请求。
为了更深入地了解在整个Auth0身份验证系统中使用的不同类型的令牌,您应该阅读Auth0使用的令牌。
https://stackoverflow.com/questions/39926832
复制相似问题