Open Closed

Before obtaining the token for login, the backend ICurrentTenant is unable to obtain the tenant ID. #9669


User avatar
0
1198462239 created

You have entered the account and password to log in.

The ICurrentTenant cannot obtain the tenant ID before the /connect/token interface.


2 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent
    • Before a user is authenticated and a token is issued (i.e., before the /connect/token endpoint is called), the ABP Framework resolves the current tenant using tenant resolvers (such as domain, header, cookie, or query string). However, the ICurrentTenant.Id will only be set if the tenant can be resolved from the incoming request.

    • During the login process (before the token is issued), if the request does not contain sufficient tenant information (for example, the __tenant header, a tenant-specific subdomain, or a query string parameter), ICurrentTenant.Id will be null. This is by design: the tenant context is established based on the request, not the user credentials.

    • To ensure ICurrentTenant is set before authentication, you must configure and use a tenant resolver that can extract the tenant from the request (such as domain/subdomain, header, or query string). For example, in a multi-tenant Angular app, the frontend should send the __tenant header or use a tenant-specific subdomain.

    • If you need to access tenant information during the login process, make sure your frontend provides the tenant identifier in the request, and your backend is configured to resolve it.

    Example configuration:

    Configure<AbpTenantResolveOptions>(options =>
    {
        options.AddDomainTenantResolver("{0}.yourdomain.com");
        options.AddHeaderTenantResolver();
        options.AddCookieTenantResolver();
        options.AddQueryStringTenantResolver();
    });
    
    • If the tenant cannot be resolved from the request, ICurrentTenant.Id will remain null until after the user is authenticated and the token is issued.

    Sources:


    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can pass the __tenant without authentication.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on September 18, 2025, 07:10