[英]401 unauthorised using a bearer token with Laravel Passport
So, I have created a site using Laravel 5.3 and I have installed passport. 所以,我使用Laravel 5.3创建了一个网站,我已经安装了护照。
As far as I can see everything is working just fine with the install and the Vue components to create a token etc. 据我所知,一切都与安装和Vue组件一起正常工作以创建令牌等。
I have created a personal token in my user area and attempted to use that to authorise with the API but I am getting 401 unauthorised every time. 我已经在我的用户区创建了一个个人令牌,并尝试使用它来使用API进行授权,但我每次都会获得401个未授权。
My headers with the request in postman 我的标题与邮递员的请求
Am i missing something with the settings here? 我错过了这里的设置吗?
I have also tried following the oauth flow in a seperate "consumer.dev" and im getting unauthorised errors there aswell. 我也尝试在单独的“consumer.dev”中跟踪oauth流程,并且我也在那里获得未经授权的错误。
I have checked the contents of my config/auth.php and that has the correct driver declaration. 我检查了我的config / auth.php的内容,并且具有正确的驱动程序声明。
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
I am a touch confused where to go from here. 我很困惑从哪里开始。 Any help is appreciated.
任何帮助表示赞赏。
Ok so thanks a ton jemaclus from laravel.io chat for this fix. 好的,所以感谢来自laravel.io聊天的一大堆jemaclus这个修复。
I will search again to find the page, but he directed me to a page that showed that if you use apache with the JWT token package used in passport, it strips the Authorization header out of the request without some modification to the virtual host in apache. 我将再次搜索以找到该页面,但他指示我到一个页面,该页面显示如果您使用带有护照中使用的JWT令牌包的apache,它会从请求中删除Authorization标头,而无需对apache中的虚拟主机进行某些修改。
As a result i switched back to nginx (moved back to using homestead) and all requests in the same project worked perfectly! 结果我切换回nginx(回到使用宅基地)并且同一项目中的所有请求都完美无缺!
In my case i was using Laragon as a test environment (ships with apache on-board, and not nginx) 在我的情况下,我使用Laragon作为测试环境(船上带有apache,而不是nginx)
Put this into your vhost conf file 把它放到你的vhost conf文件中
RewriteEngine On RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.+)$ RewriteCond%{HTTP:授权} ^(。+)$
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteRule。* - [E = HTTP_AUTHORIZATION:%{HTTP:Authorization}]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.