Skip to content

Commit 8e01521

Browse files
authored
Add Client-ID header to Twitch Helix API requests (#420)
Resolves #419.
1 parent 05f00bd commit 8e01521

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/AspNet.Security.OAuth.Twitch/TwitchAuthenticationConstants.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@ public static class Claims
2020
public const string ProfileImageUrl = "urn:twitch:profileimageurl";
2121
public const string Type = "urn:twitch:type";
2222
}
23+
24+
public static class Headers
25+
{
26+
public const string ClientId = "Client-ID";
27+
}
2328
}
2429
}

src/AspNet.Security.OAuth.Twitch/TwitchAuthenticationHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
5050
using var request = new HttpRequestMessage(HttpMethod.Get, Options.UserInformationEndpoint);
5151
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
5252
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", tokens.AccessToken);
53+
request.Headers.Add(TwitchAuthenticationConstants.Headers.ClientId, Options.ClientId);
5354

5455
using var response = await Backchannel.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, Context.RequestAborted);
5556
if (!response.IsSuccessStatusCode)

0 commit comments

Comments
 (0)