Yii的api沒法認證Authorization的錯誤

在使用token的出現錯誤php

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

極可能是因爲apache服務器上須要配置.htaccess文件,要加上一行:web

SetEnvIf Authorization 「(.*)」 HTTP_AUTHORIZATION=$1apache

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
相關文章
相關標籤/搜索