swagger Error: response status is 401
Hi. I've a c# web project; it's about a phonebook with two entities: user and contact. I use Swagger to prove the endpoints and it's works with the user's ones but throw an error in the case of contacts's endpoints. The project has jwtSecurityToken, it's generates correctly but i haven't get the contact's endpoints works. The console only indicates: "Failed to load resource: the server responded with a status of 401". If someone can help me, I could send parts of the code and review the error. And this is the remote repo https://github.com/AyeVillagra/AgendaTelefonicaApi
Thanks!
GitHub
GitHub - AyeVillagra/AgendaTelefonicaApi
Contribute to AyeVillagra/AgendaTelefonicaApi development by creating an account on GitHub.
10 Replies
401 is unauthorized - something about your auth stuff isnt working
I've yet to check the actual code you posted, but have you verified that the token contains the claims you expect?
I not understand so much about the verified claims (and c# general), but i've also check the code with of my colegues and don't find differences about it.
looking at your code, I dont see any auth policies being declared?
okay, so the only thing your code checks is that a JWT is passed and that it passes validation
ignore the claims then, but this probably means the token you are issuing isnt passing validation?
manually verify a token
how I can verify manually the token?? and why it works for the user's endpoints? any idea?
because they are unauthorized 😄
they allow any and all calls
vs
🤦 okey, i'll try changing that.. thanks!
I mean, it will just give you 401s on the usercontroller too
your token creation looks fine at a glance, but I must admit JWT authentication isnt my area of expertise
and you are SURE you are passing the token to the server, right? 😄
i think so... the authentication pass in the swagger and i can see it in the request.. but I don't have enough knowledge to see if everything is ok. I feel like I'm going round in circles about the same thing and perhaps the error is in another part 😵💫
yeah debugging stuff thats going on in the middleware isnt trivial
Hi! using Postman instead of Swagger, the endpoints works with the Token. Mystery.