-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Auth.cs
48 lines (47 loc) · 2.18 KB
/
Auth.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
using System.Text.Json;
namespace FortniteChecker
{
internal static class Auth
{
internal static Modal.AuthRoot GetAuth(AuthClient authClient, string AuthCode)
{
using (HttpClient http = new HttpClient())
{
http.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", authClient.Authorization);
http.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded");
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("grant_type", "authorization_code"),
new KeyValuePair<string, string>("code", AuthCode),
});
var response = http.PostAsync("https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token", content).GetAwaiter().GetResult();
string resp = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
return JsonSerializer.Deserialize<Modal.AuthRoot>(resp);
}
}
internal class Modal
{
public class AuthRoot
{
public string access_token { get; set; }
public int expires_in { get; set; }
public DateTime expires_at { get; set; }
public string token_type { get; set; }
public string refresh_token { get; set; }
public int refresh_expires { get; set; }
public DateTime refresh_expires_at { get; set; }
public string account_id { get; set; }
public string client_id { get; set; }
public bool internal_client { get; set; }
public string client_service { get; set; }
public List<object> scope { get; set; }
public string displayName { get; set; }
public string app { get; set; }
public string in_app_id { get; set; }
public string device_id { get; set; }
public string product_id { get; set; }
public string application_id { get; set; }
}
}
}
}