Cannot add value because header 'Authorization' does not support multiple values.
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- api, authentication
Research direction
Start in src/OpenFga.Sdk/ApiClient/BaseClient.cs at line 55 and inspect the OpenFgaApi and ApiClient construction shown in the stack trace. Use src/OpenFga.Sdk.Test/Api/OpenFgaApiTests.cs, especially UseCustomHttpClient, as the regression case. Done means creating OpenFgaApi twice with the same custom HttpClient and ApiToken completes without an exception.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- C#
- Stars
- 85
- Forks
- 18
- Avg merge
- 23h 28m
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openfga/dotnet-sdk
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
openfga/dotnet-sdk#192 · 1 reaction ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
openfga/dotnet-sdk#148 · 1 reaction ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 30/100
openfga/dotnet-sdk#137 · 5 comments ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 25/100
openfga/dotnet-sdk#127 ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 65/100
openfga/dotnet-sdk#124 · 1 comment ·
All issues in openfga/dotnet-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100