I want to create a test page on my website with a button. Upon clicking, users should log in to their Gmail accounts and receive a list of email subjects. In other words, there should be no predefined settings for OAuth. Question: should the workflow be like:
The way OAuth works is you have an app registered with google that you use to connect. That is your client ID and secret. That would stay the same for all users
then it uses a link to sign in with to connect your account.
When someone connects their account, it redirects back to the page. That is crucial. The app (n8n in this case) needs information from that redirect. It gives an access token and a refresh token. Simply put, the page needs to redirect back to your logged in n8n.
Maybe there is a way around this with n8n, I’m not sure it would probably be possible with self hosted but it would be some work.
There isn’t much possibility to jerry rig a solution like redirecting or anything because google will catch it and block it (because that is a common hacking method)
If you want to make this work you would probably have to set up your own auth service. But again, you can’t dynamically use different credentials so you would need to do all custom requests anyway, which would mean you would need to handle OAuth yourself and refresh the tokens which is possible but likely not practically possible considering the question.
Wish i could help more. Sorry for the very long winded way of saying not possible, figured i would just add some context
It’s unclear why it’s not possible, as many other services operate this way. Yes, they may not use n8n, but I don’t think that’s relevant. For example, clickup.com allows you to choose a ready-made workflow and connect the specified services under your credentials.
If not with OAuth, does it mean we need to use the code node?
OAuth2 isn’t as simple as just assigning an API key
It can be implemented differently in different apps. I don’t think there is much more to the story than that unless you get into the nuts and bolts of how it works
When registering an Oauth2 credential in n8n is seems to only accept the redirect link when you press the connect account button.
I just made and send a custom auth link to test it in a cloud account and it didn’t work, which would be the approach you would need to take if you were to try to work around this