Starting with Blazor, issue with retrieving access token within the DelegatingHandler
📰 Reddit r/webdev
Learn to handle authentication tokens in Blazor using DelegatingHandler and JWT provider
Action Steps
- Create a custom DelegatingHandler to handle authentication tokens
- Inject the JWT provider instance using the IHttpContextAccessor
- Use the IHttpContextAccessor to access the HttpContext and retrieve the access token
- Configure the DelegatingHandler to use the retrieved access token
- Test the DelegatingHandler with a sample request to verify authentication
Who Needs to Know This
Backend developers and Blazor specialists will benefit from understanding how to manage authentication tokens in a DelegatingHandler
Key Insight
💡 Use IHttpContextAccessor to access the HttpContext and retrieve the access token in the DelegatingHandler
Share This
🔒 Handle auth tokens in #Blazor with DelegatingHandler and JWT provider! 🚀
Key Takeaways
Learn to handle authentication tokens in Blazor using DelegatingHandler and JWT provider
Full Article
Probably a beginner question, I have authentication with Identity and a login method that can get the access token and place it in a JWT provider. But because this happens on the UI thread, I can't inject the same JWT provider instance when in the DelegatingHandler since that one is in a different DI scope. I get a different instance which did not get the access token in the login. So no comm with server. I asked chatgpt but it's that point where i
DeepCamp AI