"Authorization" Header propagation with Hot Chocolate and nswag API Client not working

275 views Asked by At

Very strange issue on a C# project with few important things.

  • Hot Chocolate for GraphQL
  • Header propagation for forwarding the HTTP Headers to API's
  • nswag generated API Clients

I followed the whole tutorial here: https://craftbakery.dev/http-header-propagation-aspnet-core/

And doesnt matter that I do:

services.AddHttpClient<IClient, Client>(
    c =>
    {
        c.DefaultRequestHeaders.Add("Omg", "what the ...");
        c.DefaultRequestHeaders.Add("Accept-Language", "english");
        c.DefaultRequestHeaders.Add("Authorization", "Okay");
    });

The target method is like in the guide.

[HttpGet]
public IHeaderDictionary Get()
{
    // Return all headers API received.
    return Request.Headers;
}

But the real output then is on direct call:

{
"Omg": [
    "what the ..."
],
"Accept-Language": [
    "english"
],
"Authorization": [
    "Okay"
]
}

And when I try it via the sample project (which uses the nswag generated API Client).

{
"Omg": [
    "what the ..."
],
"Accept-Language": [
    "english"
]
}

I searched in the whole project for Authorization because I tought it could be removed somehow. But must be in that "in between layer".

Some ideas what the issue could be?

0

There are 0 answers