C
C#2y ago
jov

❔ Invalid JWT token postman when validating

hi everyone, i am a beginner here. I am having a problem about validate JWT token that already took me a week to resolve it. but didn't find the solution.
18 Replies
jov
jovOP2y ago
so before validate a token, i have a register endpoint in postman. like this
jov
jovOP2y ago
jov
jovOP2y ago
after i register, i can login to the system. when i use login endpoint, it will return me a accound details and jwt token which will be used later for crud operation (there is authorization system for admin and user). since i already successfully logged in as an admin, i will get a jwt token. however, the problem is, as an admin, i can not do crud operations (such as: get all accounts). I checked the token in jwt.io and the token returns the user id. but why the program can not validate the token?????
jov
jovOP2y ago
jov
jovOP2y ago
here is my validatetoken method
jov
jovOP2y ago
jov
jovOP2y ago
here is my generateJWTtoken method
jov
jovOP2y ago
jov
jovOP2y ago
please help me, i am so desperate..
friedice
friedice2y ago
What does the full error message say? And have you debugged your validate method?
jov
jovOP2y ago
i finally can resolve this issue..... the problem "bearer error = "invalid_token" , error_description="The signature key was not found" has been changed into "Unauthorized" which resides in the AuthorizeAttribute.cs
jov
jovOP2y ago
the error has been changed into this
jov
jovOP2y ago
jov
jovOP2y ago
im sorry, but im kinda confused to debug the validate method since it just returns "error in here meaning it's either not logged in or unauthorized" but this token was from admin role..
jov
jovOP2y ago
GitHub
CMSWebAPI/CMSWebAPI at master · sunnyjovita/CMSWebAPI
Contribute to sunnyjovita/CMSWebAPI development by creating an account on GitHub.
jov
jovOP2y ago
i can also share screen if you dont mind to help me..
friedice
friedice2y ago
How are you getting and setting roles? Is account in the authorization method null?
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server