Advertisement
Levjski

Untitled

Jun 6th, 2020
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. public class AuthenticationService
  2.     {
  3.  
  4.         private static readonly HttpClient client = new HttpClient();
  5.  
  6.         public static async Task<bool> ProcessAuthenticationAsync(string code)
  7.         {
  8.  
  9.             var apiEndPoint = "https://discord.com/api/v6/oauth2/token";
  10.  
  11.             //var data = new CodeAuthRequest
  12.             //{
  13.             //    Client_Id = "610549254980632628",
  14.             //    Client_Secret = "eGJl-F2lWfNSVJ37gTFtewc9hIKnSqgE",
  15.             //    Grant_type = "'authorization_code'",
  16.             //    Code = code,              
  17.             //    RedirectUri = "https://www.nopressureffxiv.com/authentication/discordauth",
  18.             //    scope = "'identify email connections'"
  19.             //};
  20.  
  21.             var values = new Dictionary<string, string>
  22.             {
  23.                 { "Client_ID", "610549254980632628" },
  24.                 { "Client_Secret", "eGJl-F2lWfNSVJ37gTFtewc9hIKnSqgE" },
  25.                 { "Grant_type", "authorization_code" },
  26.                 { "Code", code },
  27.                 { "RedirectUri", "https://www.nopressureffxiv.com/authentication/discordauth" },
  28.                 { "scope", "identify email connections"}
  29.             };
  30.  
  31.             var content = new FormUrlEncodedContent(values);
  32.  
  33.             var response = await client.PostAsync(apiEndPoint, content);
  34.  
  35.             var responseString = await response.Content.ReadAsStringAsync();
  36.  
  37.  
  38.  
  39.             return true;
  40.         }
  41.  
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement