Laravel未检测到标头和JWT包中发送的身份验证令牌 [英] Laravel not detecting auth token sent in the header and JWT package

查看:121
本文介绍了Laravel未检测到标头和JWT包中发送的身份验证令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个Ionic应用程序,并且还开始使用Laravel作为API.在邮递员和爱奥尼(Ionic)之前,一切工作都很好,直到我发送令牌为止.

使用一个名为Satellizer的软件包进行角度处理,它将令牌存储在本地存储中.

我的问题是,我收到未提供令牌的错误.

在邮递员中,如果致电:/api/v1/authenticate/user?token = tokenkey

然后它可以正常工作,如果我也将带有在url参数中设置的标记的相同url硬编码为http请求,那么它也可以正常工作.

但是,使用邮递员并将标题中的授权参数设置为:

token : tokenkey

我再次收到缺少的令牌错误.在角度上,向/api/v1/authenticate/user发出请求时,我检查了标头参数,可以看到授权已设置为"Bearer tokenkey".

任何帮助,为什么Laravel不会把它捡起来?我找到了有关Apache删除auth标头的信息,并添加了以下内容:

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

重新启动我在MAMP上的Apache配置文件,但同样出现问题.

还有其他建议吗?

解决方案

尝试使用

RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

在您的public/.htaccess中.

StackOverflow上的相关问题: Apache中的Laravel获取标头值

Github上的相关问题: https://github.com/dingo/api/issues/54 https://github.com/sahat/satellizer/issues/300

I have set up a Ionic app and also started using Laravel for the API. Everything works great in postman and Ionic up until the point where I sent the token.

Using a package called Satellizer for angular, it adds the token in local storage to the header.

My issue is, I receive a token not provided error.

In postman, if call: /api/v1/authenticate/user?token=tokenkey

Then it works fine, if I also hard code that same url with the token set in the url params in angular as a http request then it also works.

However, when using postman and setting the authorisation params in the header to:

token : tokenkey

I get the missing token error again. In angular, when making the request to /api/v1/authenticate/user I have checked the header params and can see that a Authorisation has been set as " Bearer tokenkey".

Any help why its not getting picked up by Laravel? I have found information about Apache removing the auth header and added this:

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

To my Apache config file on MAMP, restarted but same issue.

Any more suggestions?

解决方案

Try using

RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

in your public/.htaccess.

Related issue on StackOverflow: Laravel in Apache getting header value

Related issues on Github: https://github.com/dingo/api/issues/54 and https://github.com/sahat/satellizer/issues/300

这篇关于Laravel未检测到标头和JWT包中发送的身份验证令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆