如何查看护照个人令牌是否过期或吊销?

时间:2021-05-20 02:09:14

标签: php laravel oauth-2.0 laravel-passport

我使用 Laravel 作为我的 React 应用程序的后端 API。如果令牌已过期或被撤销访问权限,我想返回一条错误消息。但是,在我的 Authenticate 中间件上,我只能捕获 AuthenticationException。此异常仅返回消息“未验证”。下面是我当前在 Authenticate 中间件中的代码

public function handle($request, Closure $next, ...$guards) {
    try {
        $this->authenticate($request, $guards);
    } catch (AuthenticationException $e) {
        $data['token'] = false;

        return ResponseServices::error(__('Auth.token_expired', []))
            ->data($data)
            ->toJson();
    }

    return $next($request);
}

我尝试使用 OAuthServerException 和 Throwable 捕获异常,但无法捕获它。只能捕获 AuthenticationException。

但是,如果我在可报告函数的处理程序类中添加 Throwable,我能够获得此信息 enter image description here

是否可以在我的中间件中获取提示消息?

0 个答案:

没有答案
相关问题