feat: add x-super-properties header

The x-super-properties header is an important header that contains info about the client with a launch signature. if this header is not provided, discord may flag requests and cause accounts to be banned/restricted
This commit is contained in:
Wave Dev 2026-03-12 15:15:57 +00:00 committed by GitHub
parent 6647f90ced
commit 89a2dabf2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,13 +37,37 @@ public class DiscordClient(
{ {
using var request = new HttpRequestMessage(HttpMethod.Get, new Uri(_baseUri, url)); using var request = new HttpRequestMessage(HttpMethod.Get, new Uri(_baseUri, url));
// Don't validate because the token can have special characters // Authorization header
// https://github.com/Tyrrrz/DiscordChatExporter/issues/828
request.Headers.TryAddWithoutValidation( request.Headers.TryAddWithoutValidation(
"Authorization", "Authorization",
tokenKind == TokenKind.Bot ? $"Bot {token}" : token tokenKind == TokenKind.Bot ? $"Bot {token}" : token
); );
// add browser headers like x-super-properties and user-agent
// this is really important as discord flags requests that dont have valid xsp header
if (tokenKind != TokenKind.Bot)
{
try
{
var headersJson = await Http.Client.GetStringAsync(
"https://gist.githubusercontent.com/MinerPL/731977099ca84bef7ad0a66978010045/raw/stable.headers.json",
innerCancellationToken
);
var userHeaders = JsonSerializer.Deserialize<Dictionary<string, string>>(headersJson);
if (userHeaders is not null)
{
foreach (var kv in userHeaders)
request.Headers.TryAddWithoutValidation(kv.Key, kv.Value);
}
}
catch
{
}
}
var response = await Http.Client.SendAsync( var response = await Http.Client.SendAsync(
request, request,
HttpCompletionOption.ResponseHeadersRead, HttpCompletionOption.ResponseHeadersRead,