active-directory-b2c-dotnet-webapp-and-webapi icon indicating copy to clipboard operation
active-directory-b2c-dotnet-webapp-and-webapi copied to clipboard

Sign up / Sign in failed

Open guobinC opened this issue 4 years ago • 3 comments

I cloned the source code 15 Dec 2021, use VS2019 to build on master branch and run. Without any code change, try to Sign up / Sign in, it reports:

Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details.

image

Same error when I tried to use my own B2C instance.

guobinC avatar Dec 15 '21 05:12 guobinC

After set breakpoint to notification.Response.Redirect("/Home/Error?message=" + notification.Exception.Message);

the detail error message is:

Unable to get authorization code Could not load file or assembly 'Microsoft.Identity.Client, Version=4.37.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).

guobinC avatar Dec 15 '21 06:12 guobinC

I issued pull request #119 to address this and to fix a problem that was occurring when your B2C policy names use mixed case and TasksController.AcquireTokenForScopes() calls were failing to silently acquire a token to access the sample API.

Turbo549 avatar Dec 16 '21 21:12 Turbo549

I had the same problem and adding "/tfp" to AadInstance parameter in web.config fixed it.

<add key="ida:AadInstance" value="https://parrotexamcom.b2clogin.com/tfp/{0}/{1}" />

I could login, however api call fails now.

Account always null, GetAccountAsync could not find any account in AcquireTokenForScopes method.

var account = await cca.GetAccountAsync(ClaimsPrincipal.Current.GetB2CMsalAccountIdentifier());

My user flows are named by using capital letters like B2C_1_SIGNUP_SIGNIN. Thanks to @Turbo549, by changing web.config values to lower case like b2c_1_signup_signin fixed the issue. Now the sample apps are working for me.

hercul1017 avatar Dec 17 '21 16:12 hercul1017

I can confirm that changing from B2C_1_SignupAndSignIn to b2c_1_signupandsignin in <add key="ida:SignUpSignInPolicyId" value="b2c_1_signupandsignin" /> fixed the problem calling API. The whole sample works as expected.

ganeshan avatar Apr 10 '23 20:04 ganeshan