Open Closed

SignInManager is not providing Provider key - Azure B2C #3661


User avatar
0
techieasp@gmail.com created
  • ABP Framework version: v4.4.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • *Architecture: Micro service

I am trying to implement Azure B2C authentication. With current implementation, I am successfully receiving loginInfo from SignInManager.GetExternalLoginInfoAsync() except ProviderKey value. On first time login, registration entries are adding properly. But, due to blank provider key, UserManager is retuning first user every time. Any help would be grateful. Please check my code snapshot in AbpAccountPublicWebModule.cs :

.AddOpenIdConnect("AzureOpenId","Azure B2C",options =>
 {
     options.SignInScheme = IdentityConstants.ExternalScheme;

     options.ClientId = configuration["AzureAD:ClientId"];
     options.Authority = configuration["AzureAD:Authority"];
     options.SignedOutRedirectUri = configuration["App:SelfUrl"] + "Account/Logout";
     options.ResponseType = OpenIdConnectResponseType.IdToken;

     options.SaveTokens = true;

     options.MetadataAddress = configuration["AzureAD:Instance"];//"https://<tennant>.b2clogin.com/<tennant>.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=B2C_1_SignUp_SignIn";

     options.GetClaimsFromUserInfoEndpoint = true;
     options.ClaimActions.MapAll();

     var clientSecret = configuration["AzureAD:ClientSecret"];
     if (!clientSecret.IsNullOrEmpty())
     {
         options.ClientSecret = clientSecret;
     }

     options.Events = new OpenIdConnectEvents()
     {

         OnTokenValidated = (context) =>
         {

             var email = context.Principal.FindFirstValue("emails"); //initial test:emails => email first when multiple emails
             ClaimsIdentity claimsId = context.Principal.Identity as ClaimsIdentity;
             claimsId?.AddClaim(new Claim(ClaimTypes.NameIdentifier, $@"{email}"));
             claimsId?.AddClaim(new Claim(AbpClaimTypes.Email, $@"{email}"));

             return Task.FromResult(0);
         }
     };

1 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    , I am successfully receiving loginInfo from SignInManager.GetExternalLoginInfoAsync() except ProviderKey value.

    Can you share a brand new project that can reproduce the problem, liming.ma@volosoft.com

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11