Advertisement
UniverseLauncher

Untitled

Oct 22nd, 2021
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. using Newtonsoft.Json;
  2. using RestSharp;
  3. using System;
  4. using System.Diagnostics;
  5. using System.Runtime.CompilerServices;
  6.  
  7. namespace Epic
  8. {
  9. public class Auth
  10. {
  11. public Auth()
  12. {
  13. }
  14.  
  15. private static string DeviceToAccount()
  16. {
  17. RestClient restClient = new RestClient("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/deviceAuthorization");
  18. RestRequest restRequest = new RestRequest(1);
  19. restRequest.AddHeader("Authorization", string.Concat("Bearer ", Auth.DeviceToken()));
  20. restRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded");
  21. dynamic obj = JsonConvert.DeserializeObject(restClient.Execute(restRequest).get_Content());
  22. Process.Start(new ProcessStartInfo((string)obj.verification_uri_complete)
  23. {
  24. UseShellExecute = true
  25. });
  26. string content = " ";
  27. do
  28. {
  29. RestClient restClient1 = new RestClient("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token");
  30. RestRequest restRequest1 = new RestRequest(1);
  31. restRequest1.AddHeader("Authorization", "Basic OThmN2U0MmMyZTNhNGY4NmE3NGViNDNmYmI0MWVkMzk6MGEyNDQ5YTItMDAxYS00NTFlLWFmZWMtM2U4MTI5MDFjNGQ3");
  32. restRequest1.AddHeader("Content-Type", "application/x-www-form-urlencoded");
  33. restRequest1.AddParameter("grant_type", "device_code");
  34. restRequest1.AddParameter("device_code", obj.device_code);
  35. content = restClient1.Execute(restRequest1).get_Content();
  36. }
  37. while (content.Contains("error"));
  38. return (string)JsonConvert.DeserializeObject(content).access_token;
  39. }
  40.  
  41. private static string DeviceToken()
  42. {
  43. RestClient restClient = new RestClient("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token");
  44. RestRequest restRequest = new RestRequest(1);
  45. restRequest.AddHeader("Authorization", "Basic OThmN2U0MmMyZTNhNGY4NmE3NGViNDNmYmI0MWVkMzk6MGEyNDQ5YTItMDAxYS00NTFlLWFmZWMtM2U4MTI5MDFjNGQ3");
  46. restRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded");
  47. restRequest.AddParameter("grant_type", "client_credentials");
  48. dynamic obj = JsonConvert.DeserializeObject(restClient.Execute(restRequest).get_Content());
  49. return (string)obj.access_token;
  50. }
  51.  
  52. public static string ExchangeCode()
  53. {
  54. RestClient restClient = new RestClient("https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/exchange");
  55. RestRequest restRequest = new RestRequest(0);
  56. restRequest.AddHeader("Authorization", string.Concat("Bearer ", Auth.DeviceToAccount()));
  57. dynamic obj = JsonConvert.DeserializeObject(restClient.Execute(restRequest).get_Content());
  58. return (string)obj.code;
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement