It’s pretty cool that recently I get to know that, there is a way to get the user ID from Passport Token. I am glad to share that information with my readers.
Let’s Get Started
Sharing an API token below
So, here is the situation, you guys don’t know which website this API Token belongs to, Right? Ok! Then how?
It’s a very simple and humble technique.
Just visit the website https://jwt.io/ and paste the API token into the input box titled Encoded.
After placing the code you will get the decoded data on the other side. Before that, you need to understand something the token contains 3 parts, which are separated with a dot (.). As you can see in the above image with a separate colour.
The first part is the HEADER section, the second part is the PAYLOAD which contains the data we need and the 3rd part is the VERIFY SIGNATURE.
So as I told you the User ID is situated in the second part. Here is the screenshot.
As you can see from the screenshot the object sub is highlighted and that’s the User ID of the User of that Passport Token.