You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When generating the interface implementation using any other way than a few particular overloads of the RestService.For method, AuthorizationHeaderValueGetter supplied in RefitSettings is quietly ignored. This is caused by the fact that RestService only injects the handler chain with a AuthenticatedHttpClientHandler when it creates its own httpClient, not when such client is supplied by the user.
This is not documented anywhere, even though running into this issue must be fairly common, after a quick search, I can find one such example from 2018: #573
There are a few ways I can see this being remediated:
When receiving an httpClient from the user, the AuthorizationHeaderValueGetter should get injected into the handler chain.
The AuthorizationHeaderValueGetter should be made public, so that you can pass it as an inner handler to your custom client.
At the very least this should be documented somewhere.
Step to reproduce
Use a particular overload of RestService.For (e. g. this one) or any overload of services.AddRefitClient
Supply an AuthorizationHeaderValueGetter in RefitSettings
Create a request with [Headers("Authorization: Bearer")]
Reproduction repository
No response
Expected behavior
The delegate stored in AuthorizationHeaderValueGetter should get called and the returned token should be put into the Authorization header. This is silently ignored.
Screenshots 🖼️
No response
IDE
No response
Operating system
No response
Version
No response
Device
No response
Refit Version
No response
Additional information ℹ️
No response
The text was updated successfully, but these errors were encountered:
Describe the bug 🐞
When generating the interface implementation using any other way than a few particular overloads of the RestService.For method,
AuthorizationHeaderValueGetter
supplied in RefitSettings is quietly ignored. This is caused by the fact that RestService only injects the handler chain with aAuthenticatedHttpClientHandler
when it creates its own httpClient, not when such client is supplied by the user.This is not documented anywhere, even though running into this issue must be fairly common, after a quick search, I can find one such example from 2018: #573
There are a few ways I can see this being remediated:
AuthorizationHeaderValueGetter
should get injected into the handler chain.AuthorizationHeaderValueGetter
should be made public, so that you can pass it as an inner handler to your custom client.Step to reproduce
AuthorizationHeaderValueGetter
inRefitSettings
[Headers("Authorization: Bearer")]
Reproduction repository
No response
Expected behavior
The delegate stored in
AuthorizationHeaderValueGetter
should get called and the returned token should be put into the Authorization header. This is silently ignored.Screenshots 🖼️
No response
IDE
No response
Operating system
No response
Version
No response
Device
No response
Refit Version
No response
Additional information ℹ️
No response
The text was updated successfully, but these errors were encountered: