Advertisement
kej

Untitled

kej
Nov 17th, 2020 (edited)
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.IO;
  5. using System.Net;
  6. using System.Net.Http;
  7. using System.Text;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. using Newtonsoft.Json;
  11. using StwDaily.Models;
  12.  
  13. namespace StwDaily
  14. {
  15. class Program
  16. {
  17. static async Task Main(string[] args)
  18. {
  19. CancellationTokenSource cancelTokenSource = new CancellationTokenSource();
  20. CancellationToken token = cancelTokenSource.Token;
  21. MainModel data;
  22. ProcessStartInfo psi = new ProcessStartInfo
  23. {
  24. FileName = "https://www.epicgames.com/id/logout?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Fid%2Flogin%3FredirectUrl%3Dhttps%253A%252F%252Fwww.epicgames.com%252Fid%252Fapi%252Fredirect%253FclientId%253Dec684b8c687f479fadea3cb2ad83f5c6%2526responseType%253Dcode",
  25. UseShellExecute = true
  26. };
  27. // Process.Start(psi);
  28. Console.WriteLine("Enter fnauth code: ");
  29. var code = Console.ReadLine();
  30. data = await GetToken(code);
  31. var errorCode = data.errorCode;
  32. var access_token = data.access_token;
  33. var accout_id = data.account_id;
  34. if (access_token == null && accout_id == null)
  35. {
  36. cancelTokenSource.Cancel();
  37. Console.WriteLine($"Error: {errorCode}");
  38. }
  39. await GetReward(access_token, accout_id, token);
  40. }
  41. static async Task<MainModel> GetToken(string code)
  42. {
  43. MainModel data;
  44. var nvc = new List<KeyValuePair<string, string>>();
  45. nvc.Add(new KeyValuePair<string, string>("grant_type", "authorization_code"));
  46. nvc.Add(new KeyValuePair<string, string>("code", $"{code}"));
  47. Uri apiReq = new Uri("https://account-public-service-prod.ol.epicgames.com/account/api/oauth/token");
  48. var httpClientHandler = new HttpClientHandler();
  49. HttpClient client = new HttpClient(handler: httpClientHandler, disposeHandler: true);
  50. HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Post, apiReq) { Content = new FormUrlEncodedContent(nvc) };
  51. req.Headers.TryAddWithoutValidation("Connection", "keep-alive");
  52. req.Headers.TryAddWithoutValidation("Authorization", "basic ZWM2ODRiOGM2ODdmNDc5ZmFkZWEzY2IyYWQ4M2Y1YzY6ZTFmMzFjMjExZjI4NDEzMTg2MjYyZDM3YTEzZmM4NGQ=");
  53. var resp = await client.SendAsync(req);
  54. string jsonContent = await resp.Content.ReadAsStringAsync();
  55. data = JsonConvert.DeserializeObject<MainModel>(jsonContent);
  56. return data;
  57. }
  58. static async Task GetReward(string access_token, string account_id, CancellationToken token)
  59. {
  60. if (token.IsCancellationRequested)
  61. {
  62. return;
  63. }
  64. Uri apiReq = new Uri($"https://fortnite-public-service-prod11.ol.epicgames.com/fortnite/api/game/v2/profile/{account_id}/client/ClaimLoginReward?profileId=campaign");
  65. var httpClientHandler = new HttpClientHandler();
  66. HttpClient client = new HttpClient(handler: httpClientHandler, disposeHandler: true);
  67. var req = new HttpRequestMessage(HttpMethod.Post, apiReq);
  68. req.Content = new JsonContent("{}");
  69. req.Headers.TryAddWithoutValidation("Authorization", $"bearer {access_token}");
  70. var resp = await client.SendAsync(req);
  71. string jsonContent = await resp.Content.ReadAsStringAsync();
  72. if (resp.StatusCode == HttpStatusCode.OK)
  73. Console.WriteLine("Your daily reward should be claimed.");
  74. else Console.WriteLine("Something went wrong :(");
  75. }
  76. }
  77.  
  78. }
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement