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

Created on 29 Nov 2019  路  5Comments  路  Source: tymondesigns/jwt-auth

Subject of the issue

This is the original issue: #1729
It was closed because it could be fixed by executing php artisan jwt:secret followed by php artisan config:cache.

But my question is: why does this happen initially? I created a repository to reproduce this error. Why does this happen on a clean installation? I did execute the commands and then it worked but I think it should work "out of the box".

This is the repo: ricardoboss/jwt-fatal-repro
This is the diff to a default Laravel 6.6 installation: a552a1c

Your environment

| Q | A
| ----------------- | ---
| Bug? | maybe
| New Feature? | no
| Framework | Laravel
| Framework version | 6.6.0
| Package version | 1.0.0-rc.5
| PHP version | 7.3.7

Steps to reproduce

If you are using PhpStorm, you can use the file api.http to execute and test the API.

Otherwise just use something like Postman to execute requests to the API.

Expected behaviour

No error

Actual behaviour

Error

Most helpful comment

I too seem to be experiencing the same issue. The strange thing on my end its that the error appears when trying to get the user details. The authentication phase works well enough. So any idea on how to fix this issue would be useful.

I am using Laravel 6.9.0 and my PHP version is 7.4.

I have however found something strange. I am using Laradock as my dev environment and everything is working fine but fails to work on my live server.

I have already ran the commands below on the live server and still not getting anywhere

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

All 5 comments

I too seem to be experiencing the same issue. The strange thing on my end its that the error appears when trying to get the user details. The authentication phase works well enough. So any idea on how to fix this issue would be useful.

I am using Laravel 6.9.0 and my PHP version is 7.4.

I have however found something strange. I am using Laradock as my dev environment and everything is working fine but fails to work on my live server.

I have already ran the commands below on the live server and still not getting anywhere

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

If you do not execute php artisan config:cache, the keys will be loaded from the .env file and you need to lock it when calling the file read function to read the .env file, so reading may fail during high concurrency.

I too seem to be experiencing the same issue. The strange thing on my end its that the error appears when trying to get the user details. The authentication phase works well enough. So any idea on how to fix this issue would be useful.

I am using Laravel 6.9.0 and my PHP version is 7.4.

I have however found something strange. I am using Laradock as my dev environment and everything is working fine but fails to work on my live server.

I have already ran the commands below on the live server and still not getting anywhere

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

I had to run all of those commands before I could get it working.

Subject of the issue

This is the original issue: #1729
It was closed because it could be fixed by executing php artisan jwt:secret followed by php artisan config:cache.

But my question is: why does this happen initially? I created a repository to reproduce this error. Why does this happen on a clean installation? I did execute the commands and then it worked but I think it should work "out of the box".

This is the repo: ricardoboss/jwt-fatal-repro
This is the diff to a default Laravel 6.6 installation: a552a1c

Your environment

Q A
Bug? maybe
New Feature? no
Framework Laravel
Framework version 6.6.0
Package version 1.0.0-rc.5
PHP version 7.3.7

Steps to reproduce

If you are using PhpStorm, you can use the file api.http to execute and test the API.

Otherwise just use something like Postman to execute requests to the API.

Expected behaviour

No error

Actual behaviour

Error

So, that's happens because you no specify the JWT_SECRET = your token here
And reject the resquest

The solution is, config your env variables or place where you have the JWT_SECRET request that will be good

I will add a check for missing secret and throw an exception so this is clearer in future :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aofdev picture aofdev  路  3Comments

mihailo-misic picture mihailo-misic  路  3Comments

johncloud200 picture johncloud200  路  3Comments

phamduong picture phamduong  路  3Comments

agneshoving picture agneshoving  路  3Comments