mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-12 22:25:38 -04:00
Change how user token is sent in requests
This commit is contained in:
parent
0d816cee5d
commit
dd9da4831e
1 changed files with 4 additions and 7 deletions
|
@ -32,13 +32,10 @@ namespace DiscordChatExporter.Core.Services
|
|||
const string apiRoot = "https://discordapp.com/api/v6";
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Get, $"{apiRoot}/{resource}/{endpoint}"))
|
||||
{
|
||||
// Add url parameter for the user token
|
||||
if (token.Type == AuthTokenType.User)
|
||||
request.RequestUri = request.RequestUri.SetQueryParameter("token", token.Value);
|
||||
|
||||
// Add header for the bot token
|
||||
if (token.Type == AuthTokenType.Bot)
|
||||
request.Headers.Authorization = new AuthenticationHeaderValue("Bot", token.Value);
|
||||
// Set authorization header
|
||||
request.Headers.Authorization = token.Type == AuthTokenType.User
|
||||
? new AuthenticationHeaderValue(token.Value)
|
||||
: new AuthenticationHeaderValue("Bot", token.Value);
|
||||
|
||||
// Add parameters
|
||||
foreach (var parameter in parameters)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue