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
Is your feature request related to a problem? Please describe.
It would be useful to register the same API client for multiple accounts. Imagine the following situation:
Account A
Account B
Based on some data from the request, I would like to be able to select an appropriate account and set a correct Authorization header.
Setting the Authorization header requires obtaining an access token. This logic is already done in the delegating HTTP handler. Unfortunately, the only way to pass some data to that handler (and indicate which account should be used) is to add the Property option, for example:
Describe alternatives you've considered
As mentioned above, we can alternatively use the Property option or register Refit clients for different interfaces. However, neither of these approaches is convenient.
Describe suggestions on how to achieve the feature
Maybe adding an API for .NET 8 and greater to register keyed Refit clients could solve that issue.
Additional context
Feel free to suggest other ideas 🙂
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
It would be useful to register the same API client for multiple accounts. Imagine the following situation:
Based on some data from the request, I would like to be able to select an appropriate account and set a correct
Authorization
header.Setting the
Authorization
header requires obtaining an access token. This logic is already done in the delegating HTTP handler. Unfortunately, the only way to pass some data to that handler (and indicate which account should be used) is to add theProperty
option, for example:If the client has multiple endpoints, it is not a convenient way to do that. We can use keyed services instead.
Describe the solution you'd like
Keyed services were introduced in .NET 8. Instead of using the approach mentioned above, we could do:
And later use an
IKeyedServiceProvider
orIServiceProvider
to get the appropriate client:Describe alternatives you've considered
As mentioned above, we can alternatively use the
Property
option or register Refit clients for different interfaces. However, neither of these approaches is convenient.Describe suggestions on how to achieve the feature
Maybe adding an API for .NET 8 and greater to register keyed Refit clients could solve that issue.
Additional context
Feel free to suggest other ideas 🙂
The text was updated successfully, but these errors were encountered: