title: Microsoft Graph Api OAuth return status code 200 instead of 302 (Not redirect to login Page)
body: <p>To Get Token for Microsoft Graph API. This is the first Call to let authentication user (microsoft) and get code for calling token service.Request properly sent but instead of getting status code 302 so that it can be redirected to login page. I am getting status code 200.</p>
  
   <pre class="lang-cs prettyprint-override"><code>public async Task&lt;string&gt; GetBToken()
  {
      string url = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?"; //https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?
      HttpClientHandler clientHandler = new HttpClientHandler();
      clientHandler.UseDefaultCredentials = true;
      clientHandler.AllowAutoRedirect = true;
  
      using(var client = new HttpClient(clientHandler))
      {
          client.BaseAddress = new Uri(url);
          // We want the response to be JSON.
          client.DefaultRequestHeaders.Accept.Clear();
          client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
  
          url = url + "grant_type=authorization_code&amp;client_id=" + appId + "resource=https://graph.microsoft.com/ &amp;response_mode=form_post&amp;response_type=code&amp;redirect_uri=http://localhost/5341/Home/AddC &amp;state=12345&amp;scope=" + string.Join(" ", scopes1);
  
          var request = new HttpRequestMessage(HttpMethod.Get, url);
          var result1 = client.SendAsync(request).Result;
  
          result1.EnsureSuccessStatusCode();
  
          string jsonString = await result1.Content.ReadAsStringAsync(); // await response.Content.ReadAsStringAsync();
  
          return jsonString;
      }
  }
  </code></pre>