Remove that again, since we're using cookies
This commit is contained in:
parent
73932635f8
commit
5f97bcfa71
@ -1,7 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
@ -45,16 +47,17 @@ namespace ChaosBot.WebServer.App
|
||||
}
|
||||
|
||||
[HttpGet("user")]
|
||||
public IActionResult GetUser(string access_token)
|
||||
public IActionResult GetUser()
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", access_token);
|
||||
if (!Request.Cookies.TryGetValue("access_token", out string accessToken))
|
||||
accessToken = null;
|
||||
|
||||
HttpResponseMessage response;
|
||||
using (HttpRequestMessage requestMessage =
|
||||
new HttpRequestMessage(HttpMethod.Get, "https://discord.com/api/v7/users/@me"))
|
||||
{
|
||||
requestMessage.Headers.Authorization =
|
||||
new AuthenticationHeaderValue("Bearer", access_token);
|
||||
new AuthenticationHeaderValue("Bearer", accessToken);
|
||||
response = client.SendAsync(requestMessage).GetAwaiter().GetResult();
|
||||
}
|
||||
string responseString = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
@ -64,16 +67,17 @@ namespace ChaosBot.WebServer.App
|
||||
}
|
||||
|
||||
[HttpGet("guilds")]
|
||||
public IActionResult GetGuilds(string access_token)
|
||||
public IActionResult GetGuilds()
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", access_token);
|
||||
if (!Request.Cookies.TryGetValue("access_token", out string accessToken))
|
||||
accessToken = null;
|
||||
|
||||
HttpResponseMessage response;
|
||||
using (HttpRequestMessage requestMessage =
|
||||
new HttpRequestMessage(HttpMethod.Get, "https://discord.com/api/v7/users/@me/guilds"))
|
||||
{
|
||||
requestMessage.Headers.Authorization =
|
||||
new AuthenticationHeaderValue("Bearer", access_token);
|
||||
new AuthenticationHeaderValue("Bearer", accessToken);
|
||||
response = client.SendAsync(requestMessage).GetAwaiter().GetResult();
|
||||
}
|
||||
string responseString = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit d5f6beff41569ca8b8cf6e38fa48a03a32824623
|
||||
Subproject commit 205122b26ade4c897300fe23682fe6b47609c6be
|
||||
Loading…
Reference in New Issue
Block a user