title: AADSTS50059: No tenant-identifying information found when acquiring the code using "{prompt", "none"}"
body: <p>So I use <code>ADAL</code> library to get id token.
  I got the code sample  from here 
  <a href="https://stackoverflow.com/questions/43488511/acquire-aad-token-using-asp-net-web-forms/43537198#43537198">sample code</a></p>
  
  <p>However, if I set the query string <code>prompt</code> to <code>none</code>. I would get this annoying message <code>AADSTS50059: No tenant-identifying information found in either the request or implied by any provided credentials.</code> If the user is not logged in when getting the code. And the screen will hang in the Microsoft login window.</p>
  
  <p>I need to set it as <code>"prompt", "consent"</code> so even not logged in the user can still perform sign in/consent. But I wan to simply the process, not to get the user go through this sign in/consent every time.</p>
  
  <p>Is there a way to do it so that for not already sign in user an call back error is returned instead of this error and hanging there forever?</p>
  
  <p>According to the <a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow" rel="nofollow noreferrer">doc</a>, <code>{prompt", "none"}</code> should be a valid configuration.</p>
  
  <p>I copy the sample code here for convenient purpose:</p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
      {
          if (Request.Params["code"] != null)
          {
              var accesstoken = AcquireTokenWithResource(resource: "https://graph.microsoft.com/");
  
              Response.Write(accesstoken);
          }
      }
  
  
      protected void Button2_Click(object sender, EventArgs e)
      {
          GetAuthorizationCode();
      }
  
      public void GetAuthorizationCode()
      {
          JObject response = new JObject();
  
          var parameters = new Dictionary&lt;string, string&gt;
              {
                  { "response_type", "code" },
                  { "client_id", "clientid" },
                  { "redirect_uri", "http://localhost:8099/WebForm1.aspx" },
                  { "prompt", "none"},
                  { "scope", "openid"}
              };
  
          var requestUrl = string.Format("{0}/authorize?{1}", EndPointUrl, BuildQueryString(parameters));
  
          Response.Redirect(requestUrl);
  
      }
      public string AcquireTokenWithResource(string resource)
      {
          var code = Request.Params["code"];
          AuthenticationContext ac =
      new AuthenticationContext(string.Format("https://login.microsoftonline.com/{0}", "tenantID"
                                ));
          ClientCredential clcred =
              new ClientCredential("clientID", "clientSecret");
          var token =
              ac.AcquireTokenByAuthorizationCodeAsync(code,
                         new Uri("http://localhost:8099/WebForm1.aspx"), clcred,resource).Result.AccessToken;
  
          return token;
      }
      private string BuildQueryString(IDictionary&lt;string, string&gt; parameters)
      {
          var list = new List&lt;string&gt;();
  
          foreach (var parameter in parameters)
          {
              list.Add(string.Format("{0}={1}", parameter.Key, HttpUtility.UrlEncode(parameter.Value)));
          }
  
          return string.Join("&amp;", list);
      }
  
      protected string EndPointUrl
      {
          get
          {
              return string.Format("{0}/{1}/{2}", "https://login.microsoftonline.com", "tenantID", @"oauth2/");
          }
      }
  </code></pre>