title: OneDrive for Business :"invalid_request","error_description":"AADSTS90014: The request body must contain the following parameter: 'grant_type
body: <p>I'm trying to integrate the OneDrive for Busines to a Web Form App.<br>
  For this I use the documentation given at <a href="https://dev.onedrive.com/auth/aad_oauth.htm" rel="nofollow noreferrer">this url</a><br>
  In web Form App I have two Pages:<br>
  First one is Login page which have a button for login<br>
  On login button click I create a GET Request to OneDrive for Business API using the following code:</p>
  
  <pre><code>HttpClient client = new HttpClient();
              Redirecturi = Uri.EscapeDataString(Redirecturi);
              string url = string.Format("https://login.windows.net/common/oauth2/authorize?response_type=code&amp;client_id={0}&amp;redirect_uri={1}", ClienId, Redirecturi);
              var response = client.GetAsync(url);
              var json = response.Result.Content.ReadAsStringAsync();
              Label2.Text = json.Result;
  </code></pre>
  
  <p>When I click the login button it takes me to micorosoft login service and sends me back to <code>callback.aspx</code> page with access code (Redirect URI configured on azure)</p>
  
  <p>I got the access code.<br>
  On the second page I redeem the access code and make a POST request to get the Authentication token.
  Here is the code for the second page:</p>
  
  <pre><code>private string BaseUri="https://login.windows.net/common/oauth2/token";
      public string Redirecturi = "http://localhost:51642/CallBack.aspx";
      public string ResourcesId = "https://api.office.com/discovery/";
      private string ClienId = "180c6ac4-5829-468e-.....-822405804862"; ///truncated//azure 
      private string ClientSecert = "G4TAQzD8d7C4...OE6m366afv8XKbTCcyXr4=";//truncated
      protected void Page_Load(object sender, EventArgs e)
      {
          if (!string.IsNullOrEmpty(Request.QueryString[OAuthConstants.AccessToken]))
          {
              // There is a token available already. It should be the token flow. Ignore it.
              return;
          }
          if (!string.IsNullOrEmpty(Request.QueryString[OAuthConstants.Code]))
          {
              string _accessCode = Request.QueryString[OAuthConstants.Code];
              HttpClient client = new HttpClient();
             // BaseUri = Uri.EscapeDataString(BaseUri);
              Redirecturi = Uri.EscapeDataString(Redirecturi);
              ResourcesId = Uri.EscapeDataString(ResourcesId);
              string url = string.Format("{0}?client_id={1}&amp;redirect_uri={2}&amp;grant_type=authorization_code&amp;client_secret={3}&amp;code={4}&amp;grant_type=authorization_code&amp;resource={5}", BaseUri, ClienId, Redirecturi, ClientSecert, _accessCode, ResourcesId);
              var response = client.PostAsync(url, null);
              var json = response.Result.Content.ReadAsStringAsync();
              Response.Write(json);
          }
      }
  </code></pre>
  
  <p>But instead of Response I am get the following error. Which say include the <code>grant_type</code> in url. I have already added (you can check in code).
  I get same error the same error without including it.</p>
  
  <p><strong>Here is the error</strong></p>
  
  <pre><code>{"error":"invalid_request","error_description":"AADSTS90014: The request body must contain the following parameter: 'grant_type'.\r\nTrace ID: 2adb3a7f-ceb1-4978-97c4-3dc2d3cc3ad4\r\nCorrelation ID: 29fb11a0-c602-4891-9299-b0b538d75b5f\r\nTimestamp: 2015-07-15 09:58:42Z","error_codes":[90014],"timestamp":"2015-07-15 09:58:42Z","trace_id":"2adb3a7f-ceb1-4978-97c4-3dc2d3cc3ad4","correlation_id":"29fb11a0-c602-4891-9299-b0b538d75b5f","submit_url":null,"context":null}
  </code></pre>
  
  <p>Please help to know where or what is getting wrong.<br>
  Any kind of help will be appreciable </p>