Laravel 5.5 使用 api.token 疑问
升级到5.5后,在日志里发现了大量的报错信息,如下:
[2017-09-12 11:08:20] local.ERROR: The resource owner or authorization server denied the request. {"exception":"[object] (League\\OAuth2\\Server\\Exception\\OAuthServerException(code: 9): The resource owner or authorization
..... 省略
>handle(Object(Illuminate\\Http\\Request))
#41 {main}
但是api访问均正常返回。于是开始分析。
\vendor\league\oauth2-server\src\AuthorizationValidators\BearerTokenValidator.php(93):
League\OAuth2\Server\Exception\OAuthServerException::accessDenied('The JWT string ...');
throw OAuthServerException::accessDenied($exception->getMessage());
public static function accessDenied($hint = null, $redirectUri = null)
{
return new static(
'The resource owner or authorization server denied the request.',
9,
'access_denied',
401,
$hint,
$redirectUri
);
}
很奇怪的是,既然抛出了这个异常,那为什么访问是正常的呢???
我在请求api时候
axios.defaults.headers.common['X-CSRF-TOKEN'] = window._csrf
axios.defaults.headers.common['Authorization'] = `Bearer ${window._token}`
推荐文章: