TomDoesTech / REST-API-Tutorial-Updated

https://www.youtube.com/watch?v=BWUi6BS9T5Y
574 stars 283 forks source link

Getting "jwt malformed" upon debugging verify token method #1

Closed joegitau closed 2 years ago

joegitau commented 3 years ago

Hi Tom,

For starters, thank you for taking the time to review this issue.

This is related to an issue I have been getting after following your Youtube tutorial - it is related to verification of tokens - whereby upon debugging the verify method, i get an error: jwt malformed.

Here is the repo to my project - https://github.com/joegitau/node-typescript-api

tomanagle commented 3 years ago

I cloned your repo and tested it out, it worked fine for me which leads me to think the issue might be with the secret you have set in your .env file. Public and private keys need to maintain their exact formatting. Here is the .env file I used for reference:

ACCESS_TOKEN_SECRET=-----BEGIN RSA PRIVATE KEY-----
MIICWwIBAAKBgQCmHlmcXHt4r6yg1dQytsiMMuJM2CWjDvwaMcszpD2pCglp/tsy
LFM7iqBsf2o/M1S6L5JwIN4Kb+Xd79Ccu0lCNpFLe8tf9f06TohYJGaPvaolyUiN
Gs7gwYXQwRNScy575koH2BXM8R7hSfesoMDBSsDwtlrgwkiMoLFUK500ZQIDAQAB
AoGAFMrZtouQ3NNITT1WeR6NzZaU4r9vPpCil3jCEW2uVhkugnjm4MnRhTNdzxbH
qq93HHLV5nkGsdG9uODKgMOkcJRv/ofJ+ms6BADm5bQMtDIHA27esWFoQxa1eATK
Apznj8X33NfGPkd2mSTdlZMQfiig85Mix4V1OTDRE9laIuECQQDfXfu4XV2ms9C7
NCWSib3DHtinsq/irg0krgbZYQH/OrFNLt0vq4MlALgnYYSvIDEj20MuVq3iRZyP
V4Wg4kINAkEAvmM/ir1tWNqlz0hhyg4/BzVHBJ7QI9KqgzQkVov6ajW+gQZbUpcZ
9uhuvvKUpxGnfebjfMU7QzrfpqxU2SAduQJAVmEB90oj7VOcZMjFvuWFfO9w2WlA
m2izrHugKnBZVVpdNnvpDYZGMQkWLiSIKzFHz5X7ZPAgTmCdKtGt24mkAQJAFyiz
fgj02C4gpUpEuvNor1PHw8QdxX3GyBb7pJt6ZpkLB17ilPVUbzhu4ENZ2cjH+wSu
/2pufwsWUYv89jx14QJAbkTQSBVw3vDaSD/+f2d94qJJzHpvvxatkP0B8jR3zCwF
dCZqVwZQyc+p4/7W24Rf1Z1xmO578sY4snvbeTFiuw==
-----END RSA PRIVATE KEY-----
DB_URI=mongodb://localhost:27017/rest-api
joegitau commented 3 years ago

Alright. Thanks for taking time to look into this. I will address that and hopefully I will get it sorted out.

I just recently subscribed to your channel and overall I was impressed with the manner at which you structure your projects and expound on matters with ease. I can't wait to see more of your tutorials.

replete commented 3 years ago

FYI: Had the same issue on the newer Jest implementation repo, based on this codebase.

tomanagle commented 2 years ago

Try this: https://youtu.be/FzKrfwplips