Jwt-auth: Argument 3 passed to Lcobucci\JWT\Signer\Hmac::doVerify() must be an instance of Lcobucci\JWT\Signer\Key, null given

Created on 21 Dec 2018  路  27Comments  路  Source: tymondesigns/jwt-auth

Subject of the issue

Describe your issue here.

Your environment

| Q | A
| ----------------- | ---
| Bug? | no
| New Feature? | no
| Framework | Laravel
| Framework version | 5.7
| Package version | 11.0.0-rc.3
| PHP version | 7.x.y

Steps to reproduce

Tell us how to reproduce this issue.
After Pushing code to live server and generating jwt key and clearing config cache. I get Argument 3 passed to Lcobucci\JWT\Signer\Hmac::doVerify() must be an instance of Lcobucci\JWT\Signer\Key, null given, error

Expected behaviour

Tell us what should happen

Actual behaviour

Tell us what happens instead

Most helpful comment

Run php artisan jwt:secret, that works for me

All 27 comments

Error occurred because of Config Cached and i know that and clear cache multiple time with
php artisan config:clear but no luck but after running php artisan config:cache command i recached config file and error was gone :-)

voy a volverme loco, no consigo una solucion

Thanks

Run php artisan jwt:secret, that works for me

I ran php artisan jwt:secret but I'm still getting the error.

Argument 3 passed to Lcobucci\JWT\Signer\Hmac::doVerify() must be an instance of Lcobucci\JWT\Signer\Key, null given, called in vendor/lcobucci/jwt/src/Signer/BaseSigner.php on line 44 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Argument 3 passed to Lcobucci\\JWT\\Signer\\Hmac::doVerify() must be an instance of Lcobucci\\JWT\\Signer\\Key, null given, called in vendor/lcobucci/jwt/src/Signer/BaseSigner.php on line 44 at vendor/lcobucci/jwt/src/Signer/Hmac.php:29)
[stacktrace]
#0 vendor/lcobucci/jwt/src/Signer/BaseSigner.php(44): Lcobucci\\JWT\\Signer\\Hmac->doVerify('-\\x9Ek\\xD5@\\xD3_Y\\xB3%A\\xB0+\
\\xD6...', 'eyJ0eXAiOiJKV1Q...', NULL)
#1 vendor/lcobucci/jwt/src/Signature.php(47): Lcobucci\\JWT\\Signer\\BaseSigner->verify('-\\x9Ek\\xD5@\\xD3_Y\\xB3%A\\xB0+\
\\xD6...', 'eyJ0eXAiOiJKV1Q...', NULL)
#2 vendor/lcobucci/jwt/src/Token.php(201): Lcobucci\\JWT\\Signature->verify(Object(Lcobucci\\JWT\\Signer\\Hmac\\Sha256), 'eyJ0eXAiOiJKV1Q...', NULL)
#3 vendor/tymon/jwt-auth/src/Providers/JWT/Lcobucci.php(136): Lcobucci\\JWT\\Token->verify(Object(Lcobucci\\JWT\\Signer\\Hmac\\Sha256), NULL)
#4 vendor/tymon/jwt-auth/src/Manager.php(101): Tymon\\JWTAuth\\Providers\\JWT\\Lcobucci->decode('eyJ0eXAiOiJKV1Q...')
#5 vendor/tymon/jwt-auth/src/JWT.php(200): Tymon\\JWTAuth\\Manager->decode(Object(Tymon\\JWTAuth\\Token))
#6 vendor/tymon/jwt-auth/src/JWT.php(136): Tymon\\JWTAuth\\JWT->getPayload()
#7 vendor/tymon/jwt-auth/src/JWT.php(149): Tymon\\JWTAuth\\JWT->checkOrFail()
#8 vendor/tymon/jwt-auth/src/JWTGuard.php(79): Tymon\\JWTAuth\\JWT->check(true)
#9 vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php(297): Tymon\\JWTAuth\\JWTGuard->user()
#10 vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(237): Illuminate\\Auth\\AuthManager->__call('user', Array)
#11 app/Http/Controllers/AuthController.php(45): Illuminate\\Support\\Facades\\Facade::__callStatic('user', Array)
...

php artisan jwt:secret worked for me too. it set a key

estoy trabajando en Laragon. con servidor apache y e realizado php artisan jwt:secret y php artisan config:cache y no e optenido solucion

I am working in Laragon. with apache server and done php artisan jwt: secret and php artisan config: cache and no and opted solution

awesome, its worked using below command

php artisan jwt:secret

Run php artisan jwt:secret, that works for me

Awesome php artisan jwt:secret worked for me. Thanks

This is what worked for me:
php artisan jwt:secret
php artisan config:clear
php artisan config:cache

If you get this error in your CI tools when running tests be sure to set JWT_SECRET to something in phpunit.xml

 <server name="JWT_SECRET" value="..."/>

I came across this error when I deployed my application after testing and everything else worked well on the local server.

I noticed the following;

  • It's possible that you are getting this error when you uploaded the applications before implementing the JWT and re-uploaded directly via the Cpanel upload without reuploading the .env file.

    • if this is the case, the simplest way to solve this is my merely adding the JWT: key in your .env file (at the bottom) eg

JWT_SECRET=roCZauuldMpw5i4039393939393372y98bEWumqd9ls7Uk8DEpr0gIZ6WIWB

Hope this helps :)

This is what worked for me:
php artisan jwt:secret
php artisan config:clear
php artisan config:cache
sudo chmod 777 -Rf storage/

@Nataanthoni answer worked for me. Unfortunately, I had not set a JWT_SECRET in my .env. My bad!

This is what worked for me:

php artisan jwt:secret
php artisan config:clear
php artisan config:cache

Lumen does not have config:clear or config:cache artisan command.

This error is still present in Lumen.

l think its for laravel only

php artisan jwt:secret
Work for me. Thanks

php artisan jwt:secret

Worked for me, Thanks.

Run php artisan jwt:secret, that works for me

it works for me

Estaba probando en heroku y me funcion贸:

Obtener el secret key

heroku run bash
php artisan jwt:secret
php artisan config:clear
php artisan config:cache

Luego agregarla como variable (fuera de heroku bash)

heroku config:add JWT_SECRET={your jwt secret key}

Error occurred because of Config Cached and i know that and clear cache multiple time with
php artisan config:clear but no luck but after running php artisan config:cache command i recached config file and error was gone :-)

Just

php artisan config:clear
php artisan config:cache

Worked for me, Big Thanks.

Run - php artisan jwt:secret - that's initially not work for me. then after i use this - php artisan config:cache - now its working.

This works for me

php artisan jwt:secret
php artisan config:cache

good work for me

Thanks

this work for me
php artisan key:generate
php artisan jwt:secret
php artisan cache:clear
php artisan config:clear

Was this page helpful?
0 / 5 - 0 ratings

Related issues

therealmjk picture therealmjk  路  3Comments

johncloud200 picture johncloud200  路  3Comments

agneshoving picture agneshoving  路  3Comments

kofi1995 picture kofi1995  路  3Comments

lloy0076 picture lloy0076  路  3Comments