title: Youtube API OAuth 2.0 on UWP error 400
body: <p>when i send a Post request to <code>https://accounts.google.com/o/oauth2/token</code> get an error 400</p>
  
  <p>This is my code</p>
  
  <pre><code>private async Task&lt;string&gt; PostAsync(string requestUriString, List&lt;KeyValuePair&lt;string, string&gt;&gt; content)
  {
      string contentString = "";
      content.ForEach(kvp =&gt; contentString += WebUtility.UrlEncode(kvp.Key) + "=" + WebUtility.UrlEncode(kvp.Value) + "&amp;");
      contentString = contentString.Remove(contentString.Length - 1);
  
      WebRequest webRequest = WebRequest.Create(requestUriString) as HttpWebRequest;
      webRequest.Method = "POST";
      webRequest.ContentType = "application/x-www-form-urlencoded";
  
      TaskFactory taskFactory = new TaskFactory();
      Task&lt;Stream&gt; requestTask = taskFactory.FromAsync(webRequest.BeginGetRequestStream, webRequest.EndGetRequestStream, null);
      using (Stream requestStream = await requestTask)
      {
          using (StreamWriter streamWriter = new StreamWriter(requestStream))
          {
              streamWriter.Write(contentString);
              streamWriter.Dispose();
          }
          requestStream.Dispose();
      }
  
      string responseString = null;
      Task&lt;WebResponse&gt; responseTask = taskFactory.FromAsync(webRequest.BeginGetResponse, webRequest.EndGetResponse, null);
      WebResponse webResponse = await responseTask;
      using (Stream responseStream = webResponse.GetResponseStream())
      {
          using (StreamReader streamReader = new StreamReader(responseStream))
          {
              responseString = streamReader.ReadToEnd();
              streamReader.Dispose();
          }
          responseStream.Dispose();
      }
      return responseString;
  }
  
  private async void WebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
  {
      if (webView.DocumentTitle.StartsWith("Success code="))
      {
          string autorizationCode = webView.DocumentTitle.Substring(13);
          string responseString = await PostAsync("https://accounts.google.com/o/oauth2/token?",
              new List&lt;KeyValuePair&lt;string, string&gt;&gt;
              {
                      new KeyValuePair&lt;string, string&gt;("code",autorizationCode),
                      new KeyValuePair&lt;string, string&gt;("client_id","xxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com"),
                      new KeyValuePair&lt;string, string&gt;("client_secret","xxxxxxxxxxxxxx"),
                      new KeyValuePair&lt;string, string&gt;("redirect_uri","http://localhost/oauth2callback"),
                      new KeyValuePair&lt;string, string&gt;("grant_type","authorization_code")
              }
          );
          MessageDialog dialog = new MessageDialog(responseString);
          await dialog.ShowAsync();
      }
  }
  </code></pre>