-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Open
Labels
Description
Is your feature request related to a problem? Please describe.
I have generated C# code that for an endpoint uses two ApiKeyTokens. My problem is that while one of them is basically static, the other one is dynamic and changes from call to call.
I have tried to implement my own TokenProvider (DynamicTokenProvider) but when I register it, I can see it it registered as a singleton. I do this:
config.UseProvider<DynamicTokenProvider, ApiKeyToken>();
and this happens:
_services.AddSingleton<TTokenProvider>();
_services.AddSingleton<TokenProvider<TTokenBase>>(services => services.GetRequiredService<TTokenProvider>());
This means my tokens are fixed in time. The constructor for DynamicTokenProvider is this:
public DynamicTokenProvider(IEconomicTokenProvider tokenSource)
: base(new ApiKeyToken[2] {
new ApiKeyToken(tokenSource.AppSecretToken, Client.ClientUtils.ApiKeyHeader.X_AppSecretToken, prefix: ""),
new ApiKeyToken(tokenSource.AgreementGrantToken.Value ?? "", Client.ClientUtils.ApiKeyHeader.X_AgreementGrantToken, prefix: "")
})
IEconomicTokenProvider holds the two tokens and it is using that implementation I can modify the token.
Describe the solution you'd like
I need a way to modify the ApiKeyTokens on a per call basis. I have found no workable solution so far. I am open for suggestions.
Describe alternatives you've considered
The above is the closest I have gotten without it actually working.