sotsera / sotsera.blazor.oidc

OpenID Connect client for Blazor client-side projects
https://blazor-oidc.sotsera.com/
Apache License 2.0
20 stars 8 forks source link

Multiple usage of OidcHttpClient fails with token not available #17

Closed ChristianWeyer closed 4 years ago

ChristianWeyer commented 4 years ago

When using OidcHttpClient in a Blazor page like /conferences directly in the .razor file everything seems fine.

When I add another page for e.g. /conference/{id} which then, in turn, uses a custom service which then uses OidcHttpClient (all via DI), then this instance of OidcHttpClient does not pick up the token when doing API calls.

ChristianWeyer commented 4 years ago

I just changed my application to only use OidcHttpClient with DI in my service. Actually, this does not seem to work at all when I use OidcHttpClient in my own custom service via DI. The token is not picked up.

ChristianWeyer commented 4 years ago

One more update :-) It works when I register my custom service as scoped in DI. I had it as singleton originally.

ghidello commented 4 years ago

Yes, singleton services and scoped dependencies are an explosive mix: I've been burned by it too! :smile:

ChristianWeyer commented 4 years ago

😅🔥