From dd9da4831e7418b1e1a964cd896e482a96712d60 Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Fri, 3 Aug 2018 00:00:51 +0300 Subject: [PATCH] Change how user token is sent in requests --- DiscordChatExporter.Core/Services/DataService.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/DiscordChatExporter.Core/Services/DataService.cs b/DiscordChatExporter.Core/Services/DataService.cs index 0f528190..215aaf26 100644 --- a/DiscordChatExporter.Core/Services/DataService.cs +++ b/DiscordChatExporter.Core/Services/DataService.cs @@ -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)