48

laravel/passport:7.5.1在我的 laravel 项目中使用包,最近遇到了这个异常。任何想法?lcobucci/jwt:3.4.0我临时将包降级 为lcobucci/jwt:3.3.3

Replicating claims as headers is deprecated and will removed from v4.0. Please manually set the header if you need it replicated.

堆栈跟踪:

"exception": {
  "trace": [
    "/var/www/app/vendor/lcobucci/jwt/src/Builder.php:334",
    "/var/www/app/vendor/lcobucci/jwt/src/Builder.php:185",
    "/var/www/app/vendor/lcobucci/jwt/src/Builder.php:201",
    "/var/www/app/vendor/league/oauth2-server/src/Entities/Traits/AccessTokenTrait.php:34",
    "/var/www/app/vendor/league/oauth2-server/src/ResponseTypes/BearerTokenResponse.php:28",
    "/var/www/app/vendor/league/oauth2-server/src/AuthorizationServer.php:202",
    "/var/www/app/vendor/laravel/passport/src/PersonalAccessTokenFactory.php:114",
    "/var/www/app/vendor/laravel/passport/src/PersonalAccessTokenFactory.php:71",
    "/var/www/app/vendor/laravel/passport/src/HasApiTokens.php:67",
    "/var/www/app/app/Http/Controllers/Auth/Shop/GetTokenController.php:84",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Route.php:219",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Route.php:176",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php:680",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php:58",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php:682",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php:657",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php:623",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php:612",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:176",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30",
    "/var/www/app/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php:65",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53",
    "/var/www/app/vendor/app/dms-pubsub/src/Middlewares/CaptureCorrelationIdMiddleware.php:40",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53",
    "/var/www/app/app/Http/Middleware/TrimData.php:31",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53",
    "/var/www/app/vendor/fideloper/proxy/src/TrustProxies.php:57",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:62",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:151",
    "/var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116",
    "/var/www/app/public/index.php:55"
  ],
  "class": "ErrorException",
  "file": "/var/www/app/vendor/lcobucci/jwt/src/Builder.php:334",
  "message": "Replicating claims as headers is deprecated and will removed from v4.0. Please manually set the header if you need it replicated.",
  "code": 0
}
4

3 回答 3

161

这个问题迫使我知道laravel/passport使用thephpleague/oauth2-serverthephpleague/oauth2-server使用lcobucci/jwt“3.3.3”。

composer require lcobucci/jwt=3.3.3

如果我今天在我的应用程序上运行 composer update 后一切正常,我就不会费心检查这个。

于 2020-11-29T14:00:19.440 回答
16

对于造成混乱或问题,我深表歉意。请查看https://github.com/lcobucci/jwt/issues/550#issuecomment-733557709,了解我对为什么采用这种方法以及为什么它在我的 PoV 中不被视为 BC 中断的完整解释。

于 2020-11-25T13:09:40.403 回答
13

我知道人们如何喜欢复制和粘贴答案。我通过将此代码添加到方法中来解决app/Providers/AppServiceProvider.phpboot问题

if (config('app.debug')) {
    error_reporting(E_ALL & ~E_USER_DEPRECATED);
} else {
    error_reporting(0);
}

这是作者建议的。请参阅@Luís Cobucci 的回答。或看这里:https ://github.com/lcobucci/jwt/issues/550#issuecomment-733557709

如果您使用@Ahmed Nasser 方法要求旧版本,那么您将来可能会遇到问题。

于 2021-04-12T01:39:08.547 回答