我是靠谱客的博主 可靠小蚂蚁,这篇文章主要介绍Yii的api无法认证Authorization的错误,现在分享给大家,希望可以做个参考。

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

在使用token的出现错误

682d0a41b1a6bb93c2515b586d0c8b1368f.jpg

{
"name": "Unauthorized",
"message": "Your request was made with invalid credentials.",
"code": 0,
"status": 401,
"type": "yii\web\UnauthorizedHttpException"
} 

很可能是由于apache服务器上需要配置.htaccess文件,要加上一行:

SetEnvIf Authorization “(.*)” HTTP_AUTHORIZATION=$1

Options +FollowSymLinks
        IndexIgnore */*
        RewriteEngine on

        # if a directory or a file exists, use it directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d

        # otherwise forward it to index.php
        RewriteRule . index.php
        SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

 

转载于:https://my.oschina.net/u/3648322/blog/1920998

最后

以上就是可靠小蚂蚁最近收集整理的关于Yii的api无法认证Authorization的错误的全部内容,更多相关Yii内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(108)

评论列表共有 0 条评论

立即
投稿
返回
顶部