I am using Refit to define my HttpProxy method. I also got a custom Delegating handling a bearer token request that it inserts before the request is being sent through.
In order to generate a token, I need an ID. I am sending this ID by using headers:
Task<Response> UserInfo (string id, [Header("identity")] string identity);
The first Id is a query string and identity, header, are the same value. Thus during a call it looks very ugly:
UserInfo("234","234");
(No I don't want to read from query string as the handler is generic)
And my handler looks like this, where first I read from the header and then remove the same from the header:
if (request.Headers.TryGetValues("identity", out IEnumerable<string> values))
{
var immutableIdentity = values.ToImmutableArray();
if (!immutableIdentity.IsNullOrEmpty())
{
var identity = immutableIdentity.First();
request.Headers.Remove("identity");
return GenerateToken(identity);
}
}
Rather than using a header to communicate between a Refit proxy and HttpDelegete, what is the next possible option do I have?