Advertisement
4535992

SketchFab PoST WORK

Jan 28th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1.         async Task RunAsync()
  2.         {
  3.             using (var client = new HttpClient())
  4.             {          
  5.                 client.BaseAddress = new Uri("https://sketchfab.com/");
  6.                 client.DefaultRequestHeaders.Accept.Clear();
  7.                 client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  8.                 // HTTP POST                
  9.                 List<KeyValuePair<string, string>> body = new List<KeyValuePair<string, string>>
  10.                 {
  11.                     new KeyValuePair<string, string>("code", CODE),
  12.                     new KeyValuePair<string, string>("grant_type", "authorization_code"),
  13.                     new KeyValuePair<string, string>("client_id", CLIENT_ID),
  14.                     new KeyValuePair<string, string>("client_secret",CLIENT_SECRET),
  15.                     new KeyValuePair<string, string>("redirect_uri", REDIRECT_URI)
  16.                 };
  17.                 var content = new FormUrlEncodedContent(body);
  18.                 HttpResponseMessage response = await client.PostAsync("/oauth2/token/", content);
  19.                 if (response.IsSuccessStatusCode)
  20.                 {
  21.                     string responseStream = await response.Content.ReadAsStringAsync();
  22.                     Console.WriteLine(responseStream);
  23.                     Console.ReadLine();
  24.                 }
  25.             }
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement