Change how user token is sent in requests

pull/92/head
Alexey Golub 6 years ago
parent 0d816cee5d
commit dd9da4831e

@ -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…
Cancel
Save