✅ JWT Authorization Issue with .NET Core Web API
Hello everyone,
I am currently working on an ASP.NET Core Web API that uses JWT for authorization. I have a GetAllUsersAsync endpoint that needs to be authorized but I am facing some issues. Here is the code for the endpoint:
Here is my JWT authentication setup:
The problem I'm encountering is when I try to access the GetAllUsersAsync endpoint with a valid token, I still get unauthorized responses. It seems the token isn't correctly validated or there's something wrong with my setup.
Would appreciate any ideas or suggestions on what might be wrong.
Thank you in advance.
2 Replies
To generate the JWT token, I use the following method:
You're missing an Audience claim
You've also set ValidateIssuer to false, but you're still setting ValidIssuer 😛