Hello!
I have 2 sevices, one is a .net core web api, that is protected with auth0 from the quick start sample. The second is a blazor server app, with protection from the auth0 blazor blogpost.
I am trying to get the bearer token from the blazor app so that I can put it in the authorization header of my http client that connects to the web api. The issue is that I can’t find a way to get it.
I’ve tried getting it out of HttpContext via GetToken(“access_token”) but that returns null. I saw some posts mentioning that you should add options to AddOpenIdConnect, but those are only used in .net core 2.1, whereas I am using the new api with AddAuth0WebAppAuthentication. I also tried adding
I’m not sure why there is no clear explanation about how to find this token. Blazor Server should not use the HttpContext (per Microsoft), so all the examples out there do not apply. I think something the .net devs should do is add a token handler to the auth state provider like they do for the web assembly side.
I might also add that if there is a concern about exposure of the token to the client side, you could store in memory instead of claims.