Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add value because header 'Authorization' does not support multiple values. #89

Open
6 tasks done
jacekwielek opened this issue Jan 29, 2025 · 0 comments
Open
6 tasks done
Labels
bug Something isn't working

Comments

@jacekwielek
Copy link

jacekwielek commented Jan 29, 2025

Checklist

  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have upgraded to the latest version of OpenFGA and the issue still persists.
  • I have searched the Slack community and have not found a suitable solution or answer.
  • I agree to the terms within the OpenFGA Code of Conduct.

Description

When I pass httpClient the OpenFgaApi and use CredentialsMethod.ApiToken authorization then I've got runtime exception about duplicated Authorization http header.

The exact exception:
Cannot add value because header 'Authorization' does not support multiple values.

Expectation

No exception thrown.

Reproduction

    /// <summary>
    /// Test that reusing custom HttpClient is possible
    /// </summary>
    [Fact]
    public async Task UseCustomHttpClient() {
        var config = new Configuration.Configuration() {
            ApiHost = _host,
            Credentials = new Credentials {
                Method = CredentialsMethod.ApiToken,
                Config = new CredentialsConfig { ApiToken = "123" }
            }
        };

        var customHttpClient = new HttpClient();
        var openFgaApiCreation = () => new OpenFgaApi(config, customHttpClient);
        openFgaApiCreation();

        var exception = Record.Exception(() => openFgaApiCreation());
        Assert.Null(exception);
    }

OpenFGA SDK version

Source code from 28.01.2025

OpenFGA version

Source code from 28.01.2025

SDK Configuration

According to the documentation

Logs

System.FormatException: Cannot add value because header 'Authorization' does not support multiple values.
at System.Net.Http.Headers.HttpHeaders.ParseAndAddValue(HeaderDescriptor descriptor, HeaderStoreItemInfo info, String value)
at System.Net.Http.Headers.HttpHeaders.Add(HeaderDescriptor descriptor, String value)
at System.Net.Http.Headers.HttpHeaders.Add(String name, String value)
at OpenFga.Sdk.ApiClient.BaseClient..ctor(Configuration configuration, HttpClient httpClient) in D:\Code\dotnet-sdk\src\OpenFga.Sdk\ApiClient\BaseClient.cs:line 55
at OpenFga.Sdk.ApiClient.ApiClient..ctor(Configuration configuration, HttpClient userHttpClient) in D:\Code\dotnet-sdk\src\OpenFga.Sdk\ApiClient\ApiClient.cs:line 39
at OpenFga.Sdk.Api.OpenFgaApi..ctor(Configuration configuration, HttpClient httpClient) in D:\Code\dotnet-sdk\src\OpenFga.Sdk\Api\OpenFgaApi.cs:line 35
at OpenFga.Sdk.Test.Api.OpenFgaApiTests.<>c__DisplayClass8_0.b__0() in D:\Code\dotnet-sdk\src\OpenFga.Sdk.Test\Api\OpenFgaApiTests.cs:line 104
at OpenFga.Sdk.Test.Api.OpenFgaApiTests.<>c__DisplayClass8_0.b__1() in D:\Code\dotnet-sdk\src\OpenFga.Sdk.Test\Api\OpenFgaApiTests.cs:line 108
at Xunit.Record.Exception(Func`1 testCode) in /_/src/xunit.core/Record.cs:line 47

References

No response

@jacekwielek jacekwielek added the bug Something isn't working label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

1 participant