Open Closed

OpenIdConnectProtocolException: Message contains error: 'invalid_grant' #9328


User avatar
0
adamjenkins created

We are currently in the process of implementing multi tenancy but most likely have an odd domain setup.

Our customers will be able to go to exampleapp.com or tenant.exampleapp.com. If they go to the apex domain they will be asked to find their tenant. When the user is on the correct tenant e.g. tenant1.exampleapp.com they will have all the applications available (before logging in).

The user then clicks on an application and gets redirected to the application with the tenant in the query string e.g. app1.exampleapp.com?__tenant=tenantname. I have made a change where if the user is not already authenticated they will be redirected to auth server (exampleapp.com) with the tenant in the domain (tenant.exampleapp.com).

I have resolved the invalid issuer issue but now facing the invalid_grant error and not sure how to resolve this.

The main goal is to all the customer to have a vanity url to the landing page so it can be branded etc but the main applications (which there are 3 for our customers) are all on specific subdomains (app1, app2, app3.exampleapp.com). I have tried simply redirecting the user to the auth server with __tenant query string but the tenant gets lost in all the redirects.


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

    hi

    now facing the invalid_grant error and not sure how to resolve this.

    Can you share full debug/error logs?

    https://abp.io/support/questions/8622/How-to-enable-Debug-logs-for-troubleshoot-problems

    liming.ma@volosoft.com

    Thanks.

  • User Avatar
    0
    adamjenkins created

    Hi,

    Just sent an email with the logs and module classes.

    Thanks

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Message contains error: 'invalid_grant', error_description: 'The issuer associated to the specified token is not valid.', error_uri: 'https://documentation.openiddict.com/errors/ID2088', status code '400'.

    The issuer in your access token has a problem.

    Can you share an access token with liming.ma@volosoft.com

    Thanks.

  • User Avatar
    0
    adamjenkins created

    The issuer would have been the tenant version of the login page where as the app is using the authority.

    How do I get an access token to share with you?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Add a middleware to your https://localhost:44374 , then write the Authentication header to the logs.

    GET /https://localhost:44374 HTTP/1.1
    Host: https://localhost:44374
    Authorization: Bearer eyJhbGciOi// your access token.
    

    also enable debug/verb logs

    image.png

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    IDX10205: Issuer validation failed. Issuer: 'https://localhost:44372/'. Did not match: validationParameters.ValidIssuer: 'null' or validationParameters.ValidIssuers: '{0}.localhost'.

    Please try to add https://localhost:44372/ to ValidIssuers list.

    And your wildcard domain format: *.localhost needs the port.

    image.png

  • User Avatar
    0
    adamjenkins created

    HI,

    Valid issuers is not the problem I am facing.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Is the Message contains error: 'invalid_grant', error_description: 'The issuer associated to the specified token is not valid.' error solved?

  • User Avatar
    0
    adamjenkins created

    Applied the change and fixed the if statement and still get the invalid_grant error.

    image.png

    Instead of us redirecting the user from the auth-server to tenant.auth-server then to the app. Is there a way for the app to persist the __tenant query string when the user gets redirected to /connect/authorize then to the /account/login?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    and still get the invalid_grant error.

    Please share the new host - identitymodel.txt again.

    The issuer should end with /

    https://localhost:44372/

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 v9.3.0-preview. Updated on June 13, 2025, 11:37