title: AD B2C Invalid_grant Error during SignUp in Razor pages Web App
body: <p>I am facing the below error in my Razor pages web application using Azure AD B2C during SignUp. <strong>&quot;AADB2C90088: The provided grant has not been issued for this endpoint. Actual Value : B2C_1A_SIGNIN and Expected Value : B2C_1A_SIGNUP&quot;</strong></p>
  <p>I am using separate B2C custom policies for SignIn and SignUp. I have also created a separate AccountController that sets the PolicyName in AuthenticationProperties and calls the Challenge method.</p>
  <pre><code>        public IActionResult SignIn(
              [FromRoute] string scheme,
              [FromQuery] string redirectUri)
          {
              scheme ??= OpenIdConnectDefaults.AuthenticationScheme;
              string redirect;
              if (!string.IsNullOrEmpty(redirectUri) &amp;&amp; Url.IsLocalUrl(redirectUri))
              {
                  redirect = redirectUri;
              }
              else
              {
                  redirect = Url.Content(&quot;~/&quot;)!;
              }
  
              var properties = new AuthenticationProperties { RedirectUri = redirect };
              properties.Items[Constants.Policy] = _configuration.GetValue&lt;string&gt;($&quot;AzureAdB2C:SignInPolicyId&quot;);
              return Challenge(properties, scheme);
          }
  </code></pre>
  <p>The policy contains simple signup &amp; signin TechnicalProfiles. There is nothing fancy inside it. The SignUp flow works fine, but when it redirects from B2C to web app, it throws the Invalid grant error.</p>
  <p>AppSettings.json</p>
  <pre><code>&quot;AzureAdB2C&quot;: {
      &quot;CallbackPath&quot;: &quot;/signin-oidc&quot;,
      &quot;Instance&quot;: &quot;https://xxx.b2clogin.com/&quot;,
      &quot;ClientId&quot;: &quot;xxx&quot;,
      &quot;TenantId&quot;: &quot;xxx&quot;,
      &quot;Domain&quot;: &quot;xxx.onmicrosoft.com&quot;,
      &quot;SignedOutCallbackPath&quot;: &quot;/signout/B2C_1A_SIGNIN&quot;,
      &quot;SignUpSignInPolicyId&quot;: &quot;B2C_1A_SIGNIN&quot;,
      &quot;SignInPolicyId&quot;: &quot;B2C_1A_SIGNIN&quot;,
      &quot;SignUpPolicyId&quot;: &quot;B2C_1A_SIGNUP&quot;,
      &quot;SignInUrl&quot;: &quot;/CustomIdentity/Account/SignIn?redirectUri={0}&quot;,
      &quot;SignOutUrl&quot;: &quot;/CustomIdentity/Account/SignOut?redirectUri={0}&quot;,
      &quot;SignUpUrl&quot;: &quot;/CustomIdentity/Account/SignUp?redirectUri={0}&quot;
    }
  
  where, CustomIdentity/Account is the AccountController.
  </code></pre>
  <p>Can anyone please help on this issue? I am not sure where it is going wrong. I did debug on the <em>IdToken</em> that is obtained in the Web App by listening to <em>OpenIdConnectOptions.Events.OnAuthorizationCodeReceived</em> event. On decoding IdToken in jwt.ms, it had the acr claim as B2C_1A_SIGNUP. I am not sure where this Actual Value of B2C_1A_SIGNIN is being returned from.</p>
  <p>Any help on this is appreciated.</p>
  <p>Thanks!</p>