【问题标题】:Laravel php artisan shows error of JWTLaravel php artisan 显示 JWT 错误
【发布时间】:2016-10-23 03:59:08
【问题描述】:

对于任何 php artisan 命令,我都收到以下错误。我正在使用 laravel/dingo 包。

执行了以下导致错误的步骤

    Loading composer repositories with package information
Updating dependencies (including require-dev)                        
  - Removing rap2hpoutre/laravel-log-viewer (v0.6.1)
  - Removing dingo/blueprint (v0.1.5)
  - Installing dingo/blueprint (v0.1.6)
    Downloading: 100%         

  - Removing dingo/api (dev-master 8cd1a6c)
  - Installing dingo/api (v1.0.0-beta3)
    Downloading: 100%         

  - Removing cartalyst/support (v1.1.2)
  - Installing cartalyst/support (v1.2.0)
    Downloading: 100%         

Writing lock file
Generating autoload files
> php artisan optimize

composer update
> php artisan clear-compiled


  [Tymon\JWTAuth\Exceptions\JWTException]         
  The token could not be parsed from the request   

然后任何 php artisan 命令都显示“无法从请求中解析令牌”错误

出了什么问题。好困惑:(

【问题讨论】:

    标签: php laravel jwt dingo-api


    【解决方案1】:

    我遇到了同样的错误 - 这是因为我在我的 UserController 中使用了一个构造函数,我有一个 getAuthenticatedUser 方法调用: $user = JWTAuth::parseToken()->authenticate()

    然后在我的构造函数中设置 $this->user = $this->getAuthenticatedUser(); ——这让工匠们大吃一惊。除了删除构造函数之外,我还没有找到解决方法,如果有人有更好的建议,我也想知道。

    【讨论】:

      猜你喜欢
      • 2020-03-17
      • 2017-03-20
      • 2017-12-22
      • 2016-01-29
      • 2016-05-14
      • 2017-10-12
      • 2021-04-09
      • 2016-05-29
      • 2018-08-04
      相关资源
      最近更新 更多