Skip to content
Advertisement

jwt-auth after upgrade – get user from request token

I upgraded:

“tymon/jwt-auth”: “0.5.*”,

from a very old version, and it seems like the API has changed. I managed to fix the login, using:

JavaScript

So my login work, but all API’s that required the token – fail now.

Example of API that fail:

JavaScript

Any idea how to convert the token from the request to the user with the new API? I couldn’t find any docs about it.

I tried:

return response()->json(auth()->user());

but in this API it return empty array. only in login it works.

Advertisement

Answer

Try the following:

JavaScript

You may also explicitly set the guard when using the following syntax:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement