Laravel 接入 jwt-auth 时一个疑似插件问题的报错?

在用laravel-v5.6.28接入插件"tymon/jwt-auth":1.0.0-rc.2
按照常规步骤接入,一切OK,最后通过Post慢进行接口测试时报错
我故意没有在Authorization里面选择Type。原本应该使用Bearer Token验证,这里我留空了。
报错内容:
Argument 1 passed to Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException::__construct() must be of the type string, null given, called in /......./vendor/dingo/api/src/Auth/Auth.php on line 113

查看这行代码

protected function throwUnauthorizedException(array $exceptionStack)
{
    $exception = array_shift($exceptionStack);

    if ($exception === null) {
        $exception = new UnauthorizedHttpException(null, 'Failed to authenticate because of bad credentials or an invalid authorization header.');
    }

    throw $exception;
}

不怎么会用markdown将就看下吧】
$exception = new UnauthorizedHttpException(null, 'Failed to authenticate because of bad credentials or an invalid authorization header.');
是报错的行数,正常来讲这里应该抛出一个401的异常,并附带message“Failed to authenticate because of bad credentials or an invalid authorization header.”才对,但是却抛出了一个500的异常,Argument 1 passed to UnauthorizedHttpException::__construct() must be of the type string, null given.

通过UnauthorizedHttpException这个类可以看到,

 namespace Symfony\Component\HttpKernel\Exception;

 class UnauthorizedHttpException extends HttpException
 {

        public function __construct(string $challenge, string $message = null, \Exception $previous = null, ?int $code = 0, array $headers = array())
         {
               $headers['WWW-Authenticate'] = $challenge;

               parent::__construct(401, $message, $previous, $headers, $code);
            }
 }

____ construct 方法的第一个参数规定为string格式,但Auth.php传的时候是null,这里应该是框架和插件冲突了吧?还是其他什么问题?

有大佬能帮我解答一下嘛?

《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 1

问题解决了吗?遇到同样的问题

5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!