简体   繁体   中英

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.

I am trying to send the header as

'Authorization' => $token

The $token variable will have the authorization token as needed.

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.

尝试使用密钥x-access-token将令牌作为标头的一部分传递

我通过这样传递解决了这个问题

Authentication: Bearer : $token

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM