C
C#•4w ago
Metalkon

JwtBearer Invalid Token

I've been trying to get an old project working again and i'm trying to figure out whats wrong with my tokens being invalid, anyone who's familiar with jwtbearer have an idea on what might be happening? I'm afraid of spending days on this over a potentially tiny fix.
No description
27 Replies
Sehra
Sehra•4w ago
nothing in the logs?
Metalkon
MetalkonOP•4w ago
ahh don't have logs built into the app unless you are talking about something in the browser/vs
Sehra
Sehra•4w ago
usually in the console unless you changed it
Metalkon
MetalkonOP•4w ago
no errors in console that are specific to this request, got a couple errors on startup with an auto http request but not sure if related
Metalkon
MetalkonOP•4w ago
No description
Sehra
Sehra•4w ago
that's blazor, what about the server side?
Metalkon
MetalkonOP•4w ago
they don't reach the controller and I have no clue how to check what i'm receiving through jwtbearer itself
Mayor McCheese
Mayor McCheese•4w ago
There's some events you can add in jwtoptions Frequently they're not super helpful
Sehra
Sehra•4w ago
i think it logs at info level, so make sure you don't limit Microsoft.AspNetCore to only warning
Mayor McCheese
Mayor McCheese•4w ago
You've also got a cors error Are you even getting there
Sehra
Sehra•4w ago
cors say port 8001, but most seem to be against 8000
Metalkon
MetalkonOP•4w ago
the localhost 56429 is weird, nothing i have is 56429
Sehra
Sehra•4w ago
looks like vs browser link
Metalkon
MetalkonOP•4w ago
here's the current repo btw https://github.com/Metalkon/Blacksmith-App
Mayor McCheese
Mayor McCheese•4w ago
Out of curiosity who is your idp
Metalkon
MetalkonOP•4w ago
default vs project stuff
Mayor McCheese
Mayor McCheese•4w ago
Do you mean from a template? Or does vs have a local idp now
Metalkon
MetalkonOP•4w ago
not used to people saying "idp" are you referring to whats generating the tokens, whats sending them, etc? idk
Metalkon
MetalkonOP•4w ago
the project was created with either none or microsoft identity platform in pic. The tokens are generated by "TokenService" in the api project, and they're added to the header in customauthstateprovider blazor service, the test method for the http request is at the top of the httpclienttoken service in blazor which calls the test controller.
No description
Mayor McCheese
Mayor McCheese•4w ago
Idp would be the identity provider, auth0 and azure b2c are common I'm not sure how none would work
Sehra
Sehra•4w ago
in appsettings.development.json, change loglevel for Microsoft.AspNetCore to info and check what the jwt auth complain about
Metalkon
MetalkonOP•4w ago
Not using any 3rd party stuff
Metalkon
MetalkonOP•4w ago
Mayor McCheese
Mayor McCheese•4w ago
Has this ever worked?
Metalkon
MetalkonOP•4w ago
it did last year before i reformated my pc, i've been off and on trying to get it to work for a week now over various issues (a couple different things, but this one stumps me). i've also updated nuget packages due to some security warnings which could be related, i tried to revert though that changed nothing.
Sehra
Sehra•4w ago
try adding package Microsoft.IdentityModel.JsonWebTokens 8.3.0 as well
Metalkon
MetalkonOP•4w ago
it reached the test controller after doing that, and i can access my admin page 😮 seems that fixed it thanks for the help, everything seems to be running fine for now. 😄

Did you find this page helpful?