Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Newtonsoft.Json;
- using RestSharp;
- using System;
- using System.Diagnostics;
- using System.Runtime.CompilerServices;
- namespace Epic
- {
- public class Auth
- {
- public Auth()
- {
- }
- private static string DeviceToAccount()
- {
- RestClient restClient = new RestClient("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/deviceAuthorization");
- RestRequest restRequest = new RestRequest(1);
- restRequest.AddHeader("Authorization", string.Concat("Bearer ", Auth.DeviceToken()));
- restRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded");
- dynamic obj = JsonConvert.DeserializeObject(restClient.Execute(restRequest).get_Content());
- Process.Start(new ProcessStartInfo((string)obj.verification_uri_complete)
- {
- UseShellExecute = true
- });
- string content = " ";
- do
- {
- RestClient restClient1 = new RestClient("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token");
- RestRequest restRequest1 = new RestRequest(1);
- restRequest1.AddHeader("Authorization", "Basic OThmN2U0MmMyZTNhNGY4NmE3NGViNDNmYmI0MWVkMzk6MGEyNDQ5YTItMDAxYS00NTFlLWFmZWMtM2U4MTI5MDFjNGQ3");
- restRequest1.AddHeader("Content-Type", "application/x-www-form-urlencoded");
- restRequest1.AddParameter("grant_type", "device_code");
- restRequest1.AddParameter("device_code", obj.device_code);
- content = restClient1.Execute(restRequest1).get_Content();
- }
- while (content.Contains("error"));
- return (string)JsonConvert.DeserializeObject(content).access_token;
- }
- private static string DeviceToken()
- {
- RestClient restClient = new RestClient("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token");
- RestRequest restRequest = new RestRequest(1);
- restRequest.AddHeader("Authorization", "Basic OThmN2U0MmMyZTNhNGY4NmE3NGViNDNmYmI0MWVkMzk6MGEyNDQ5YTItMDAxYS00NTFlLWFmZWMtM2U4MTI5MDFjNGQ3");
- restRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded");
- restRequest.AddParameter("grant_type", "client_credentials");
- dynamic obj = JsonConvert.DeserializeObject(restClient.Execute(restRequest).get_Content());
- return (string)obj.access_token;
- }
- public static string ExchangeCode()
- {
- RestClient restClient = new RestClient("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/exchange");
- RestRequest restRequest = new RestRequest(0);
- restRequest.AddHeader("Authorization", string.Concat("Bearer ", Auth.DeviceToAccount()));
- dynamic obj = JsonConvert.DeserializeObject(restClient.Execute(restRequest).get_Content());
- return (string)obj.code;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement