title: This line hangs forever: authContext.AcquireTokenAsync("https://graph.windows.net", credential);
body: <p><strong>My issue is:</strong> When I use Microsoft's project, the line of code mentioned in the title runs and authenticates correctly, and I can perform operations on users as demonstrated in the "B2CGraphClient" sample project. <strong>However</strong> when I copy-and-paste <code>B2CGraphClient.cs</code> into my web application, this line of code hangs forever. How can this be?</p>
  
  <p>The line that hangs is #184 in <code>B2CGraphClient.cs</code>.</p>
  
  <p>Details:
  I am using the sample project named "B2CGraphClient" mentioned in this <a href="https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-devquickstarts-graph-dotnet" rel="nofollow noreferrer">article</a>, whose zipfile is located <a href="https://github.com/AzureADQuickStarts/B2C-GraphAPI-DotNet/archive/master.zip" rel="nofollow noreferrer">here</a>. The files require setting the variables <code>clientId</code>, <code>clientSecret</code>, and <code>tenant</code>, which I was able to set correctly to fit my AAD B2C instance. The values of these variables were also correctly set when I copied the <code>B2CGraphClient.cs</code> code into my web app project, so I don't think that is the issue.</p>
  
  <p>Clues:
  These observations could potentially be the issues:</p>
  
  <ol>
  <li>When running the Microsoft sample "B2CGraphClient" code, it does not require that a user authenticates into a web application; however, my web application does require a user enter his/her username/password before use of the Graph Client.</li>
  <li>When the line of code in the title is run in my web application, the following is the URL in the browser: <code>https://login.microsoftonline.com/&lt;my_domain&gt;.onmicrosoft.com/B2C_1_SiUpIn/......</code> I know that the <code>B2C_1_SiUpIn</code> policy name is not supposed to be in this URL. But how do I fix this?</li>
  </ol>
  
  <p>Thank you!</p>
  
  <hr>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I am posting the code which initializes the B2CGraphClient, which shows that (at least, it looks to me) the only pieces of information that are being passed into the client in order to create its credentials are the <code>clientId</code>, <code>clientSecret</code>, and <code>tenant</code> name.</p>
  
  <pre><code>    public B2CGraphClient(string clientId, string clientSecret, string tenant)
      {
          // The client_id, client_secret, and tenant are pulled in from the App.config file
          this.clientId = clientId;
          this.clientSecret = clientSecret;
          this.tenant = tenant;
  
          // The AuthenticationContext is ADAL's primary class, in which you indicate the direcotry to use.
          this.authContext = new AuthenticationContext("https://login.microsoftonline.com/" + tenant);
  
          // The ClientCredential is where you pass in your client_id and client_secret, which are 
          // provided to Azure AD in order to receive an access_token using the app's identity.
          this.credential = new ClientCredential(clientId, clientSecret);
      }
  </code></pre>
  
  <p>The <code>credential</code> is later used to authenticate the graph client:</p>
  
  <pre><code>        AuthenticationResult result = await authContext.AcquireTokenAsync(aadGraphResourceId, credential);
  </code></pre>