-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
51 lines (48 loc) · 1.73 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace ConsoleApp1
{
internal class Program
{
static async Task Main(string[] args)
{
Console.Write("Enter Email: ");
string email = Console.ReadLine();
Console.Write("Enter Password: ");
string password = Console.ReadLine();
await getToken(email, password);
}
async static Task getToken(string email, string pass)
{
string url = "https://discord.com/api/v9/auth/login";
var payload = new Dictionary<string, string>()
{
{"login", email }, { "password", pass}
};
string JsonPayLoad = JsonConvert.SerializeObject(payload);
HttpClient client = new HttpClient();
StringContent stringContent = new StringContent(JsonPayLoad, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(url, stringContent);
if (response.IsSuccessStatusCode)
{
Console.WriteLine("\nLogin Successful!");
string responseContent = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseContent);
JObject json = JObject.Parse(responseContent);
Console.WriteLine($"User ID: {json["user_id"]}");
Console.WriteLine($"User ID: {json["token"]}");
Console.ReadKey();
}
else
{
Console.WriteLine(response.ReasonPhrase);
}
}
}
}