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
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIzIiwianRpIjoiYzc5ZmFhNjI2OWQxMWQyYThlNzZiZWE2NTFhNjA5ZWM2MzEzZmNiMTMyM2Y5ZjFlMjQwMDZhOGNlODcxMWMzYjkzOGU2Njg4Zjc5MmFlYmMiLCJpYXQiOjE2NTUzNjcyMTcuNTIyMTM0LCJuYmYiOjE2NTUzNjcyMTcuNTIyMTM4LCJleHAiOjE2ODY5MDMyMTcuNTE1Mzk0LCJzdWIiOiIxMiIsInNjb3BlcyI6W119.OnvBdtzd_xRPtrCHjKipCdCGwwfRBQ6PlPOGc_P0fxVbXidatZSyyz4OPoMBaXk8S3HK9iFP6WcvbESMfKyXujRnGc3qlcIV1DWDQyg3XPInP0CjAhA1eWpPqs9YofqOq5LNJ08OEHsjzhP5L-7U5XPddDNae3SUxST960nuUBtY2h-RZ3MSY2_6Z2AbAZEAholYhJkIdtMZ4YkS3AKdB1Ir3_HFTGLAZZeI8ReKCs3vxJJNU6Gg93tCnn-GrWPYZ65QgRNjMZNtVxA1t7PXEO_-tp_zXDXvS3-tRI4uoLfny9jryNQyL8IZnP-GFZyLW2cjRUjwGKsYTGxvkIS0VeSfYa0o-m7FvWrwRMKmShVr9xFNT4poonU83LxlSeppjnRhxAcdRHbU5-hpc34F4FNKMjqG48g3SFWHl3ZFCu6xLqzs4kDOUhInVyjZPOAGQioW7IrEHXTPV4V8TPfRxbiz5rvFlGC8xaATs1ieWPsKjQLiW34mUUgEagyNGryuIOXU9c_E8_ItqP6whcLAJFI0UMhMRFBjj3hAcJaDRlZawKs0Ay1iEZkC82z5N-niiBpKOsv0Sc_CYQoCMaoUlBmySGUt1EkCR1bhG2ci1Zs2PKKYvg5_TjL4Wy_Dj4LK11IRLG9252YNoBq2MRJciyWcz2DtE_W28Cac3qETY6c
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.