[英]Authorization: Bearer {token} in the header of REST API
I am having troubles sending header in an API that handles authentication using " Authorization: Bearer {token}
" in the header. 我在使用标头中的“
Authorization: Bearer {token}
”处理身份验证的API中发送标头时遇到麻烦。
I am trying to send the header as 我正在尝试将标头发送为
'Authorization' => $token
The $token
variable will have the authorization token as needed. $token
变量将根据需要具有授权令牌。
But I get result as follow 但是我得到如下结果
HTTP_Request2_Response {#319 ▼
#version: "1.1"
#code: 401
#reasonPhrase: "Unauthorized"
I am wondering if I am sending the Authorization header correctly. 我想知道我是否正确发送了Authorization标头。
尝试使用密钥x-access-token
将令牌作为标头的一部分传递
我通过这样传递解决了这个问题
Authentication: Bearer : $token
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.