Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async Task RunAsync()
- {
- using (var client = new HttpClient())
- {
- client.BaseAddress = new Uri("https://sketchfab.com/");
- client.DefaultRequestHeaders.Accept.Clear();
- client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- // HTTP POST
- List<KeyValuePair<string, string>> body = new List<KeyValuePair<string, string>>
- {
- new KeyValuePair<string, string>("code", CODE),
- new KeyValuePair<string, string>("grant_type", "authorization_code"),
- new KeyValuePair<string, string>("client_id", CLIENT_ID),
- new KeyValuePair<string, string>("client_secret",CLIENT_SECRET),
- new KeyValuePair<string, string>("redirect_uri", REDIRECT_URI)
- };
- var content = new FormUrlEncodedContent(body);
- HttpResponseMessage response = await client.PostAsync("/oauth2/token/", content);
- if (response.IsSuccessStatusCode)
- {
- string responseStream = await response.Content.ReadAsStringAsync();
- Console.WriteLine(responseStream);
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement