The challenge is that I have 6 Gmail accounts, and duplicating the workflow for each account is becoming unmanageable. I’ve been advised to use the n8n-nodes-run-node-with-credentials-x community node to handle credentials dynamically.
Here’s what I’ve done so far:
I plan to store Service Account credentials (JSON file containing client_email and private_key) for all 6 accounts in the community node.
Since there are multiple accounts, I can’t rely on pre-defined credentials. Instead, I need to dynamically authorize each account within the workflow.
The problem I’m facing:
To authorize the Gmail API, I need an access token. However, the Service Account JSON file doesn’t directly provide this.
How do I generate an access token using the Service Account credentials?
I know that the access token expires every 1 hour.
How do I manage the token renewal dynamically for multiple accounts within my workflow?
Can anyone please help me setup just the https request authorization part?
We automatically handle the token refresh internally so you don’t need to worry about that, we also don’t you access to the tokens as it isn’t needed.
If you are planning to manually store and handle the authentication you will need to use some http request nodes to manage the authentication handshake which will likely get more complicated than having multiple workflows.
What you could do instead is use an execute workflow node that either calls a workflow that uses the correct credentials or one workflow with a switch node to call the correct node.