Open Closed

Login Error #379


User avatar
0
chanchai-mwp created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

  • ABP Framework version: v3.0.5
  • UI type: MVC
  • Tiered (MVC) or Identity Server Seperated (Angular): yes
  • Exception message and stack trace: error message: OpenIdConnectProtocolException: Message contains error: 'invalid_grant', error_description: 'error_description is null', error_uri: 'error_uri is null'.
  • Steps to reproduce the issue: Login to website

Result:

Host (host db): success Tenant1 (host db): success Tenant2 (separate tenant db): fail

Could you please help?

Thanks, Chanchai


4 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Do you initialize seed data? try run the .DbMigrator project.

  • User Avatar
    0
    chanchai-mwp created

    I do.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I will check it out.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    This is a problem.

    Try to add the following code to the .identityserver project:

    public class FormTenantResolveContributor: HttpTenantResolveContributorBase
    {
        public const string ContributorName = "Form";
    
        public override string Name => "Form";
    
        protected override string GetTenantIdOrNameFromHttpContextOrNull(
            ITenantResolveContext context,
            HttpContext httpContext) => httpContext.Request?.Form[context.GetAbpAspNetCoreMultiTenancyOptions().TenantKey];
    }
    
    Configure<AbpTenantResolveOptions>(options =>
    {
        options.TenantResolvers.Add(new FormTenantResolveContributor());
    });
    

    Try to add the following code to the .Web project:

    .AddOpenIdConnect("oidc", options =>
    {
        //.......
        
        options.Events = new OpenIdConnectEvents()
        {
            OnAuthorizationCodeReceived = receivedContext =>
            {
                if (receivedContext.Request.Cookies.ContainsKey("__tenant"))
                {
                    receivedContext.TokenEndpointRequest.SetParameter("__tenant",
                        receivedContext.Request.Cookies["__tenant"]);
                }
    
                return Task.CompletedTask;
                ;
            }
        };
    }
    
Made with ❤️ on ABP v9.1.0-preview. Updated on November 01, 2024, 05:35