public async Task <string> GetAuthToken() { _client.ClearHeaders(); _client.SetAcceptHeader(MediaTypeFormUrlEncoded); var headers = new Dictionary <string, string> { { "grant_type", "client_credentials" }, { "client_id", _clientId }, { "client_secret", _clientSecret } }; _client.SetHeaders(headers); var keyValues = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("grant_type", "client_credentials"), new KeyValuePair <string, string>("client_id", _clientId), new KeyValuePair <string, string>("client_secret", _clientSecret) }; var content = new FormUrlEncodedContent(keyValues); var result = await _client.PostAsync(OauthTokenUrl, content); var token = await result.Content.ReadAsStringAsync(); return(token); }