Gmail node with an external application

Hello,

I am wondering if this is possible.

I am creating a customer facing webapp (nodejs) and would be using Google login along with permissions to read emails.

Is it possible to use the permissions granted there to trigger requests using the gmail node in n8n.
In other words, I want to avoid having to authorize the n8n gmail node explicitly.

Thanks in advance!

Uh no sorry. It is currently sadly not possible to inject custom credentials at runtime.

If you want to make it work anyway you would have to:

  • Create the credentials via the API (currently undocumented as it is only meant to be used by the Editor-UI).
  • Add the name of the credentials into to the JSON of the workflow (that part would be simple as it is literally just one string)
  • Execute that workflow via the Execute-Workflow Node

Thanks @jan. That’s pretty much what I am looking for.

I need to figure out how create separate credentials for every user of my app and then inject it into the workflow at runtime.

I’ll try to look up the source code to figure out. Please point me to any relevant places if possible.

Thank you!

Good to hear that it was helpful.

The easiest would be to create/update credentials via the UI and then looking at what kind of data does get sent. You can find the code which creates the credentials here:

Additionally, can you find the OAuth2 related code here:

If you authenticate via OAuth2 with Google and output some information there, before it updates the credentials, you should be able to figure out quite fast how to make that work.

Good luck!