We are developing workflows within a gitpod environment, so we have a local n8n self-hosted instance in each development workspace.
We have a problem with the n8n salesforce node credentials in that salesforce requires a “fixed” url for callbacks, and our workspaces have dynamic urls
I was looking into using an oauth proxy for the callback , but there seems to be no way to
change the callback url in the credentials
add a state query parameter to the initial oauth request
Has anyone else come across this type of problem and if so, were you able to solve it ?
I know on n8n cloud we use a shared URL for all instances so it is possible, Looking at the documentation you will need to create a hooks file that sets oauth2.callback you can find a bit more on this and what it expects in the embed documentation here: Configuration | n8n Docs
Looking at the docs the settings example looks like it might just be cosmetic as there is also the backend hook that needs oauth2.callback as well so there is likely to be a 2 step process to this one to update the display value and one to set the value that is actually used.
We don’t really have any examples on what to do to get this working but I do know we have a version of it we use for n8n cloud so I know this can work it is just going to be finding the details on it.
These are great questions but sadly the hooks are not something I have spent a lot of time with myself, Typically this is a feature that would only be used by an embed or enteprise customer if you are using one of these versions it may be worth reaching out to your account manager who may be able to find more information on this from other customers using it.
So the oauth2:callback is actually working for me, using your hooks file. But it will be executed when the callback is coming back after you logged in. If I understand correctly you do want to change the callback url before doing an oauth login.
Sadly I also wasn’t able to use the frontend:settings hooks either to change the oauthCallbackUrls. I will ask internally if this is the right approach.
We’re running in a dynamic environment, so the callback url is not known up front. So I was thinking of setting up a oauth proxy, setting the callback in the IDP to use the proxy address.
So I now need 2 things from n8n
The ability to change the callback url on startup, either by a env variable or hook
the ability to add a query parameter to the initial call to the IDP so that the ouath proxy knows where to redirect to (the dynamic n8n instance) after the client has been authorised
I was hoping that the hooks would solve (1) but still have the issue with (2)
What could also be useful is a “pre-auth” hook that is run just before the credential makes it’s initial call to the idp
Hey @jmls,
here is an example backend hook file to change the callback url. The frontend:settings hook trick is to prevent n8n from overriding the urls again