GetTokenAsync with multiple JwtBearer Schemes? #25906
Unanswered
WolfspiritM
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I've set up a way to log in with two different JWT Providers. This works as expected. I did use .AddJwtBearer("provider1",...) and .AddJwtBearer("provider2"...) in Startup with SaveToken in both cases.
If I now want to access the access_token with GetTokenAsync("access_token") this fails as there is no default auth scheme. I can get the access_token via GetTokenAsync("provider1", "access_token") but I can't seem to find a way to do that depending on which auth scheme was used for the current request.
Is there any way to do that without having to manually parse the Header?
I could add the token as a claim in the Events when OnTokenValidated is called but this seems to be more like a workaround.
I have the feeling the Controller shouldn't really care about what Scheme was used when GetTokenAsync is used...it should just use the one that authenticated the current request.
Beta Was this translation helpful? Give feedback.
All reactions