title: Obtain Bearer Token using HttpClient
body: <p>I am trying to obtain bearer token:</p>
  
  <pre><code>public override async Task&lt;string&gt; Post(string path, HttpContent content) {
  
  
      var encodedConsumerKey = System.Uri.EscapeDataString("1111111111111");
      var encodedConsumerKeySecret = System.Uri.EscapeDataString("2222222222222");
      var encodedPair = Base64Encode(String.Format("{0}:{1}", encodedConsumerKey, encodedConsumerKeySecret));
  
      HttpRequestMessage request = new HttpRequestMessage{
                                          Method      = HttpMethod.Post,
                                          RequestUri  = new Uri("https://api.twitter.com/oauth2/token"),
                                          Content     = new StringContent("grant_type=client_credentials")
                                      };
      request.Headers.TryAddWithoutValidation("Authorization", String.Format("BASIC {0}", encodedPair));
      request.Headers.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded");
  
  
      var result = await HttpClient.SendAsync(request);
      return result.Content.ReadAsStringAsync().Result;
  }
  
  private static string Base64Encode(string plainText) {
      var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
      return System.Convert.ToBase64String(plainTextBytes);
  }
  </code></pre>
  
  <p>This is giving me the following error 403 'Forbidden'. Any ideas would be appreciated. </p>