問題描述
我正在使用 POSTMAN 將 GET 請求發送到帶有包含授權的標頭的 api 中.
I am using POSTMAN to send a GET request into the api with a header containing Authorization.
我知道數據頭有效,因為如果無效,路由會返回 401 錯誤.
I know the data header works because if it doesn't the route returns a 401 error.
我想像這樣獲得授權標頭:
I wanted to get the Authorization header like so:
$access_token = Request::header('Authorization');
但注意到它返回NULL.
But noticed that it returns NULL.
所以我試圖用以下方法捕捉值:
So I tried to catch the values with:
die(var_dump(Request::header()));
并注意到它不包含任何授權標頭.只需托管到 cookie 標頭.
And noticed that it doesn't contain any Authorization header. Just host to cookie headers.
更新
應該得到Authorization: Bearer ACCESS TOKEN
推薦答案
你用的是什么 POSTMAN 版本?
What POSTMAN Version did you use?
您是在本地計算機還是托管服務器上,某些托管公司不允許使用 AUTHORIZATION HEADER.
Are you on your local machine or managed server, some hosting companies don't allow AUTHORIZATION HEADER.
.htaccess 修改
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
這篇關于Laravel 獲取請求頭的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!