Skip to content

Commit 798449b

Browse files
fix: resolve ApiToken reserved header exception (#146)
ApiToken credentials now handled via BuildHeaders method instead of modifying DefaultHeaders, preventing reserved header validation error. - Extract auth token retrieval to GetAuthenticationTokenAsync() - Add comprehensive ApiClient tests - Add regression test for issue #146
1 parent d596eeb commit 798449b

File tree

4 files changed

+450
-35
lines changed

4 files changed

+450
-35
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## [Unreleased](https://github.com/openfga/dotnet-sdk/compare/v0.8.0...HEAD)
44

5+
### Fixed
6+
- fix: ApiToken credentials no longer cause reserved header exception (#146)
7+
58
## v0.8.0
69

710
### [0.8.0](https://github.com/openfga/dotnet-sdk/compare/v0.7.0...v0.8.0) (2025-10-22)

src/OpenFga.Sdk.Test/Api/OpenFgaApiTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,28 @@ public async Task ApiTokenSentInHeader() {
184184
);
185185
}
186186

187+
/// <summary>
188+
/// Test that ApiToken credentials do not cause reserved header exception
189+
/// </summary>
190+
[Fact]
191+
public void ApiTokenDoesNotSetReservedHeaderInDefaultHeaders() {
192+
var config = new Configuration.Configuration() {
193+
ApiHost = _host,
194+
Credentials = new Credentials() {
195+
Method = CredentialsMethod.ApiToken,
196+
Config = new CredentialsConfig() {
197+
ApiToken = "some-token"
198+
}
199+
}
200+
};
201+
202+
// This should not throw an exception about reserved headers
203+
config.EnsureValid();
204+
205+
// Verify that Authorization is NOT in DefaultHeaders
206+
Assert.DoesNotContain("Authorization", config.DefaultHeaders.Keys);
207+
}
208+
187209
/// <summary>
188210
/// Test that providing no client id, secret, api token issuer or api audience when they are required should error
189211
/// </summary>

0 commit comments

Comments
 (0)