Jwt Authentication error Argument 3 passed to Lcobucci\JWT\Signer\Hmac::doVerify()
Solution 1
Here's complete snippet
php artisan key:generate
php artisan jwt:secret
php artisan cache:clear
php artisan config:clear
Before run above commands make sure there is install jwt package, than check its config file name jwt.php
in config folder.
Solution 2
In fact it's the right thing to solve it:
php artisan key:generate
php artisan jwt:secret
Solution 3
This error can occur when
JWT_SECRET
is missing on the.env
JWT_SECRET
is commented in the.env
- The value of
JWT_SECRET
is wrong.
In my case, running php artisan jwt:secret
it was appending the key on the current JWT_SECRET
. So checking my .env
file, the value of JWT_SECRET
was very long and wrong (it should be 64 chars long).
To solve it:
- Open the
.env
and remove theJWT_SECRET
value (note that you have to remove it and not comment it). - Run
php artisan jwt:secret
- Run
php artisan cache:clear && php artisan config:clear
Solution 4
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) ef
JWT_SECRET=roCZauuldMpw5i4039393939393372y98bEWumqd9ls7Uk8DEpr0gIZ6WIWB
Hope this helps :)
Solution 5
php artisan jwt:secret
php artisan config:cache
These both command will be enough
Esteban
Updated on December 05, 2021Comments
-
Esteban over 2 years
I'm working on a project to learn laravel, I saw a couple of tutorials to use
jwt auth
in this. It was working good but now is show an error not always but I don't know why. this is it:Argument 3 passed to Lcobucci\JWT\Signer\Hmac::doVerify() must be an instance of Lcobucci\JWT\Signer\Key, null given, called in C:\xampp\htdocs\inmobiliaria\vendor\lcobucci\jwt\src\Signer\BaseSigner.php on line 42
Sometimes it works but not another. so I don't know what can I do. I tried with
- php artisan cache:clear
- php artisan config:clear
- php artisan jwt:secret
but the problem still there, sometimes i get good answer from server(200) but the most part of then al bad (500).
Screenshots