Yii的api无法认证Authorization的错误

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

在使用token的出现错误

Yii的api无法认证Authorization的错误_第1张图片

{
"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的错误)