-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuring multiple auth0 applications at run time #600
Comments
Hi @jagathwee - this should work and I can't see anything wrong with the code you've shared in principle.
If it's not that, I'd need to see a running app that demonstrates the issue in order to debug it for you. |
Hi @adamjmcgrath, Thanks for the information. We did not explicitly configure CallbackOptions.redirectUri. Is this mandatory when we run multiple domains? From the following piece of documentation, it is not clear whether this is mandatory or not. Anyway, we will give it a try and let you know. Thanks. --Doc-- |
I'm not sure what you're doing exactly. But, what is mandatory is that you do the code exchange with the same |
Closing - feel free to ping me if you want to continue the conversation |
Hi @adamjmcgrath, We made sure the same redirect_uri is configured in CallbackOptions and in authorizationParams. See the updated code below. We still get the same error for the App2 domain, but the default domain works fine. Do you think we are missing another configuration/variable?
|
Hi @jagathwee - I can't see anything wrong with the code you've shared. It looks like the If you can share a running example I could probably debug it for you. Or, if you can share your tenant and clientID's I might be able to figure out what's going on from your tenant logs. |
Hi @adamjmcgrath, Our tenant names have client information, so I can not share that in public. Could you please give me your email address to send you? Or I can even create an Auth0 support request if that helps. Thanks |
Yep - if you can create a support request, that would be great |
Done. I mentioned the link to this issue in the support request and provided tenants and clientIds involved. |
Hi @adamjmcgrath, We did not use the domain-specific auth0 instance for the callback. That caused the authorization code exchange flow to communicate with the wrong tenant. await handleCallback(req, res, { afterCallback, redirectUri: should be: We could get both tenants to work on the same app with this fix. Thanks, @adamjmcgrath, and Supun from Auth0 support. Best, |
Hey @jagathwee, thanks for posting this! I am doing something similar, but need to do this for potentially 20-30 different apps. It's a multi tenant kind of application. |
Hi @marcziss, That's right, initAuth0() gets called on every call for auth. Otherwise, per-domain parameters are not applied. We thought about introducing a cache for Auth0<->Domain, but we did not try it yet. Jagath |
Hey @jagathwee, appreciate the info. I'm trying to get a version of what your doing to work, but hitting a wall. Are you using the [...auth0].js file and just overriding the callback? I'm trying to adapt what you did to login so I can login to different domains but keep getting 404's I'm doing something like
and just choosing between 2 initAuth0's in the '../../tenants/bin.com/tenantAuth'; file. Did you override login? |
Hi @marcziss, Please ignore this if my response is too late. It looks like your approach is correct, but I am exactly not sure what you try to do with handeLogin(). The example I put in the comment might be helpful. |
Thanks for getting back @jagathwee ! To answer my own question above I got it working by building an instance of initAuth0(currentTenantAuth) dynmically and then overriding the ...auth0].js file and implementing the auth functions like
and also implement similar functions: callback.js,logout.js, and me.js |
@marcziss, Glad to hear that! |
Description
We configured two auth0 applications at runtime using manually created auth instances with InitAuth0(). Authentication fails with "invalid_grant (Invalid authorization code)." Please let me know: (1) whether this is supported, (2) if supported any hints on getting this to work. Thanks.
Reproduction
This is how we create the auth instance: For App1, we use the default parameters, whereas, for App2, we pass the config parameters.
With this setup, App1 works fine. The App2 authentication fails with the "invalid_grant (Invalid authorization code)" error.
Environment
AUTH0_SCOPE is the same for both apps.
The text was updated successfully, but these errors were encountered: