OAuth2: Issue connecting credentials, but only with Docker

I’m having a strange issue with connecting OAuth2 credentials and I’m not really sure how to continue to troubleshoot further. In short, when I run n8n directly (installed or through npx) I have no issues connecting the OAuth credentials with the API I’m querying; everything is working and I have no problems with my workflow. Happy days.

If I run the n8n docker image (n8nio/n8n:latest-rpi, specifically), I’m unable to connect the very same credentials, I have a 401 response with the API saying bad credentials. I suspect there might be some issues with the client ID/secret header because as far as I can tell there’s no issues on the API side. I even created new credentials to try with the API, no luck.

At this point I’m kind of stuck, I’m not really sure what to try or check next. I’m not looking forward to trying to proxy the HTTPS requests from my RasbPi in order to verify them as that will take a bit of learning for me. So before I dive into that, I was hoping someone here had some suggestions or ideas of what could be responsible for the issue I’m seeing.

Welcome to the community @nkzar!

Wow, that is really strange. The code of both versions is 100% the same. At least the n8n part. Is quite possible (actually sure) that some dependencies are different. Anyway, it would then be more likely that the Docker-Version would work and the npm one not.

Sadly do I have no Raspberry Pi to check what is going on here. Just to make sure I understand correctly. It is working on the same Raspberry Pi perfectly if you npm install n8n?

Thanks! And thanks for creating such an incredible tool.

So I did some verifying this morning: After installing n8n through NPM on the RPi, I was able to start up a new instance alongside the Docker one and connect the credentials. Using those exact same credentials in the instance of n8n running in Docker, the API returns a 403 saying Bad Credentials. I don’t think I can say with absolute certainty that the API is not at fault here, but it really doesn’t seem that way based on the previous fact.

I’m not at all familiar with Docker so I don’t really know where to start with debugging, so hopefully you are someone else can point me in the right direction! If there’s any logs or info that would help, please let me know.

In the mean time I’ll just not use Docker since apart from this issue everything else is working correctly. The Docker image was much easier to get working on the Pi since when installing from NPM it had to build sqlite and took a lot of tinkering to get it installed correctly.

Thanks a lot! That is great to hear that you enjoy n8n!

There is actually also n8n-pi which got created by @Tephlon. That makes it very simple to get started with n8n on a RPi. He has a lot of experience with n8n and RPi so maybe he has some idea what is going on here or can have a look if there is currently something wrong with the docker-image.

Hey @nkzar,

So, it sounds like the only difference between your working RPi setup and the not working RPi setup is the Docker installation. When connecting through the Docker install, you are actually going through two networks. The RPi network and the Docker network. Is it possible that the Docker network is changing the information?

I guess the other thing to take a look at is whether or not the docker container had DNS configured on it so that it can authenticate the certificate on the API end. You will get a 401 if it can’t authenticate the certificate.

One last question…is the Oauth2 credentials that you have set up requiring a response URL? if so, can you get to that response URL from somewhere on your network? What about remotely outside your network from the internet? If not, there may be holes that you need to open up in your network to allow the request in.

Let me know if that helps!

Thanks for the reply. I don’t know the answers to the questions you posed but it gives me a lot of new leads to go on, so that is very helpful. I’m not too familiar with Docker so this is good context to have.

My suspicion was that the Docker network was perhaps dropping or altering the client credential headers on the request but I’ll look into the DNS settings as well.

Thank you again, this is helpful and gives me new areas to investigate. If I ever figure it out I’ll post back or open an issue on GH.