How to dynamically set Gmail OAuth credentials per user in n8n (Client ID, Secret, Access/Refresh Tokens stored in DB

Hi everyone,
I’m building a multi-user SaaS workflow where each user connects their Gmail account to allow my backend to create Gmail Drafts on their behalf using n8n. I’m stuck at one major point: How to dynamically inject each user’s Gmail OAuth credentials into the Gmail node at runtime.
My Setup
I have multiple users, each with:

  • Gmail client ID
  • Gmail client secret
  • Gmail access token
  • Gmail refresh token
    All credentials are encrypted and stored inside my database.
    When a user signs in, my backend receives their tokens successfully.
    Now I need n8n to:
    Automatically pick that user’s credentials
    Use them in Gmail node
    Create a Draft (not send email)
    Using an HTTP Request or gmail node → n8n workflow trigger
    The Problem
    Gmail node requires selecting a credential from the credentials list — but I need per-user dynamic credentials.
    I tried:
    Passing tokens via parameters
    Creating credential via API
    Using Expressions to set OAuth fields
    Using HTTP node with raw Google API
    But Gmail node does not allow dynamic Client ID / Client Secret / Tokens.
    I want n8n to automatically:
    Receive tokens from backend
    Generate credential entry programmatically (if needed)
    Use those credentials for that workflow run
    Create Gmail Draft
    Questions
    Is there any recommended way to set Gmail OAuth credentials dynamically for each user?
    Something like runtime credentials injection?
    Can I create or update Gmail OAuth credentials via n8n API whenever a user logs in?
    If yes, how do I attach those credentials to the workflow execution?
    Is the only solution to skip Gmail Node entirely and use HTTP Request Node with Google API raw endpoints?
    If so, how do I correctly handle:
    access token refresh
    draft creation
    MIME/base64 email body encoding?
    Important Requirement
    I do not want to send emails
    → Only save email to Gmail Drafts.
    What I need guidance on
    Best architecture to handle per-user Gmail credentials
    Whether dynamic OAuth is supported
    Example of programmatically creating a draft using HTTP node with user-specific tokens
    How others have implemented multi-user Gmail integration in n8n
    Any help or example workflows would be greatly appreciated!
    Thanks! :folded_hands:

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to

 copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
1 Like

Having the same issue. Does anyone have a solution for it?