Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tymon\JWTAuth\Exceptions\JWTException: Could not create token: Implicit conversion of keys from strings is deprecated. Please use InMemory or LocalFileReference classes. #2059

Closed
jxlwqq opened this issue Nov 25, 2020 · 27 comments

Comments

@jxlwqq
Copy link

jxlwqq commented Nov 25, 2020

Subject of the issue

"lcobucci/jwt": "3.4.0"

https://github.com/lcobucci/jwt/releases/tag/3.4.0

⚠ This version also triggers E_USER_DEPRECATED errors in scenarios where we can't simply use @deprecated. Please make sure you follow the provided instructions before upgrading your production code.

Your environment

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 8.x.y
Package version 1.x.y
PHP version 7.x.y
@carloquilala
Copy link

Please check this upgrading guide

https://lcobucci-jwt.readthedocs.io/en/latest/upgrading/#v3x-to-v4x

@tai-it
Copy link

tai-it commented Nov 25, 2020

EDIT by @tymondesigns
Please install latest version to address this issue instead of switching to namshi/jose


In config\jwt.php file
Change 'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class, to 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class,
=> It works for me <3

@xtongtong
Copy link

lcobucci/jwt:3.4 has this problem, composer require lcobucci/jwt:3.3 can resolve it.

@wasddsaw
Copy link

In config\jwt.php file
Change 'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class, to 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class,
=> It works for me <3

How to fix for Lumen ?

@mstaack
Copy link

mstaack commented Nov 25, 2020

@wasddsaw publish jwt config file and load it in your bootstrap file with $app->configure()
-> https://github.com/laravel/lumen/blob/8.x/bootstrap/app.php#L62

@louisfisch
Copy link

In the meantime for those like me who uses lcobucci/jwt as a dependency of leage/league/oauth2-server or laravel/passport you can explicitly require the version 3.3.3 of the lcobucci/jwt package (until a better solution comes up) by executing:

composer require lcobucci/jwt:3.3.3 && composer update

@dcyou
Copy link

dcyou commented Nov 25, 2020

thephpleague/oauth2-server#1146

lcobucci/jwt#550 (comment)

@felipemarques-rec
Copy link

felipemarques-rec commented Nov 25, 2020

It's not working for me, the lib used is "tymon/jwt-auth": "1.*"

I received the error: Could not create token: Implicit conversion of keys from strings is deprecated. Please use InMemory or LocalFileReference classes

I change my php.ini adding in the error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE & ~E_USER_DEPRECATED and keep not working.

@dcyou
Copy link

dcyou commented Nov 25, 2020

It's not working for me, the lib used is "tymon/jwt-auth": "1.*"

I received the error: Could not create token: Implicit conversion of keys from strings is deprecated. Please use InMemory or LocalFileReference classes

I change my php.ini adding in the error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE & ~E_USER_DEPRECATED and keep not working.

question is what are the content of your composer.lock for lcobucci/jwt

@felipemarques-rec
Copy link

felipemarques-rec commented Nov 25, 2020

It's not working for me, the lib used is "tymon/jwt-auth": "1.*"
I received the error: Could not create token: Implicit conversion of keys from strings is deprecated. Please use InMemory or LocalFileReference classes
I change my php.ini adding in the error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE & ~E_USER_DEPRECATED and keep not working.

question is what are the content of your composer.lock for lcobucci/jwt

Hi @dcyou , thanks for reply, my content in the composer.lock is:

"url": "https://github.com/lcobucci/jwt.git",
                "url": "https://api.github.com/repos/lcobucci/jwt/zipball/c1123697f6a2ec29162b82f170dd4a491f524773",
                "lcobucci/jwt": "^3.2"

@dcyou
Copy link

dcyou commented Nov 25, 2020

I think you don't run that command composer require lcobucci/jwt:3.3.3 if you ran that command you also should have "lcobucci/jwt": "3.3.3", in your require of composer.json

@toramanlis
Copy link

In config\jwt.php file
Change 'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class, to 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class,
=> It works for me <3

You are now, officially my best friend

@vesper8
Copy link

vesper8 commented Nov 25, 2020

In config\jwt.php file
Change 'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class, to 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class,
=> It works for me <3

This works, make sure to run php artisan config:clear after

@bbprojectnet
Copy link

Any solution for branch 2.0?

@serdud
Copy link

serdud commented Nov 26, 2020

Any solution for branch 2.0?

downgrade lcobucci/jwt to 3.3.3

@specialtactics
Copy link

Apart from downgrading, what's the longer term solution and does package author need help to implement?

Do we need to update the package for compatibility ?

@codingstuff91
Copy link

In config\jwt.php file
Change 'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class, to 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class,
=> It works for me <3

Hi, i had the same issue and i tested this solutions and now it works fine !!! Thanks a lot for your help

@nicesome
Copy link

thanks, it's work!

@midota-phucdaivo
Copy link

In config\jwt.php file
Change 'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class, to 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class,
=> It works for me <3

Hi, i had the same issue and i tested this solutions and now it works fine !!! Thanks a lot for your help

I changed this and it' work, But response throw 401 when call refresh token api

@aslamdoctor
Copy link

In config\jwt.php file
Change 'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class, to 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class,
=> It works for me <3

That worked. I am using Laravel 8 👍

@lcobucci
Copy link

I change my php.ini adding in the error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE & ~E_USER_DEPRECATED and keep not working.

All Laravel versions override the server error_reporting configuration. I've created laravel/framework#35381 to address this issue and not break apps on deprecation messages from any library.

I really hope that gets merged and helps you all 👍

@tymondesigns
Copy link
Owner

Just catching up on all this. Looks like an upgrade to v4 is necessary, so will work on that asap. Thanks all!

@lcobucci
Copy link

@tymondesigns feel free to ping on PRs about this, would gladly help reviewing them 👍

Please check your PHP version requirements, v4 is PHP 7.4+ only. If need to support older PHP versions, you'd need to use ^3.4 || ^4.0 as version constraint. https://lcobucci-jwt.readthedocs.io/en/stable/upgrading/ should help you to achieve that.

@tymondesigns
Copy link
Owner

@tymondesigns feel free to ping on PRs about this, would gladly help reviewing them 👍

Please check your PHP version requirements, v4 is PHP 7.4+ only. If need to support older PHP versions, you'd need to use ^3.4 || ^4.0 as version constraint. lcobucci-jwt.readthedocs.io/en/stable/upgrading should help you to achieve that.

Thanks, I think the best course of action is to restrict the version to <3.4 for now. I can address the v4 upgrade in the 2.0 branch, where php 7.4 is the minimum.

@tymondesigns
Copy link
Owner

tymondesigns commented Nov 27, 2020

Closing as release has been tagged to address this https://github.com/tymondesigns/jwt-auth/releases/tag/1.0.2

@specialtactics
Copy link

Thanks @tymondesigns !

@iamwebwiz
Copy link

EDIT by @tymondesigns Please install latest version to address this issue instead of switching to namshi/jose

In config\jwt.php file Change 'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class, to 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class, => It works for me <3

This works for me as well. Thanks @tai-it 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests