Programatically passing credentials into a Workflow

Continuing the discussion from Integrations which my clients can use:

Sometimes you may want to run the same (or similar) workflows for different user accounts. For example, when embedding n8n, you may want to capture credentials for each user on your own site and automatically set up workflows to run for them.

You have two options for doing this:

  1. Create a new workflow for each user
  2. Have a single workflow and call it with different credentials for different users

The advantage of (2) is that you only have a single workflow, so making changes is easy and things stay neat. However, you would have to trigger the workflow yourself (e.g. you wouldn’t be able to use our built-in triggers for individual services)

With (1), you have no limitations on how the workflow is triggered — you create it once and it runs like any other n8n workflow. However, you will need to manage each workflow that you create.

1. Creating a new workflow for each user

Steps:

  1. Obtain the user’s credentials
    • You may wish to do this by asking them to enter an API key on a webpage, or launching an OAuth flow for them
    • You could also capture parameters for the workflow at this point if you wanted
  2. Create a credential in n8n for the user
    • You can use n8n’s frontend API for this
    • This call returns the ID of the created credential, which you will need in the next step
  3. Create the workflow in n8n for the user
    • The best way here is to have a ā€˜template’ workflow that you copy and customise
    • Fetch the JSON for the template workflow (could be via API)
    • Insert the ID of your newly-created credentials in the JSON (and any other user-specific settings you might need)
    • Create the new workflow (via API)
    • Activate it (via API)

NB: You may want to make your user-specific workflows call a single, more general workflow for the non user-specific parts. That way you reduce the chances that you’d need to changes to many workflows.

2. Calling a single workflow with different credentials

NB: For OAuth, this requires being able to set a credential using an expression, which is currently under development

Steps:

  1. Obtain the user’s credentials
    • You may wish to do this by asking them to enter an API key on a webpage, or launching an OAuth flow for them
    • You could also capture parameters for the workflow at this point if you wanted
  2. Create a credential in n8n for the user
    • You can use n8n’s frontend API for this
    • This call returns the ID of the created credential, which you will need in the next step
  3. Set up a workflow
    • The workflow needs to be triggered via a webhook, and the credentials should be sent with the webhook call (plus and user settings you need)
    • For the nodes that need the user’s credential, use an expression on the credentials field to read the credential ID from the webhook node
  4. Activate the workflow (using the n8n UI)
  5. Call the workflow
    • Call the webhook whenever you want, passing the data outlined in the previous step
5 Likes

Happily awaiting the dynamic OAuth credentials option! I’ll use it to be able to create Outlook email drafts in the corresponding user’s account. Going to create a workflow for each user that gets triggered by the main workflow and only handles the draft creation, for now!

Loving N8N so far, it’s been an amazing experience working with the tool and seeing how it is evolving. Just wanting to revisit this conversation, I’ve been able to programmatically pass credentials into a workflow where they simply require an API secret key (Notion credentials for example).

Can I ask how I would best have the same result for Google Calendar OAuth APIs, where seemingly each user will have to the google cloud console and do a bit of setup. I would prefer to have an option where users on my application (not on N8N) can just click Connect With Google and an OAuth verification pops up, and they can simply press accept (like I see most apps are able to do). Then the credentials can be passed via backend to N8N.

Happy to share more details wherever needed, thanks in advance for the help!

l’m also interested in dynamically passing credentials to nodes, which would highly increase reusability of workflows.

@sirdavidoff could you tell me, which PR is related to this feature? Is it Add authentication to credentials by janober Ā· Pull Request #2334 Ā· n8n-io/n8n Ā· GitHub?

I am reaching out to express my utmost enthusiasm for the possibility of programmatically passing credentials to N8N workflows. As an avid user of N8N, I have found it to be an exceptional platform for automating workflows, connecting various applications and services, and simplifying complex processes. The ability to programmatically pass credentials would undoubtedly elevate the functionality and versatility of this already impressive tool.

Thanks a lot. That is great to hear! I assume the following Feature Request that matches what you want to do?

If so, it would be great if you could upvote it so that we can prioritize accordingly.

I am looking for exactly this functionality as well. Do you know if it’s possible by now?

" would prefer to have an option where users on my application (not on N8N) can just click Connect With Google and an OAuth verification pops up, and they can simply press accept (like I see most apps are able to do). Then the credentials can be passed via backend to N8N."

This exactly describes what I need.

Up, It was in development since 2021. Is there any chance still ?

We should be having this feature by now. It has been a while yet the demand from the community is high

1 Like

I started evaluating n8n for my enterprise application about 2 weeks ago.

I’ve been extremely hyped and impressed pretty much every step of the way, until today.

I’m genuinely floored that this capability is not part of the core offering. I’m going to try some of the workarounds I’ve encountered today but this could very well be a non-starter for my adoption of n8n. What a shame.

I’m extremely interested in this as well and have spent the past 24 hours trying to figure out or find a solution.

I’ve found about 6 threads all asking for the same thing but unfortunately no solution. I’ve also found the community node ā€œrun-nodes-with-credentialsā€ but no luck yet getting it working.

Has anyone actually managed to develop a robust work around? Or has the native solution that has been alluded to by a couple of n8n-ers been implemented?

As a couple of others have alluded to this is pretty much a make or break capability for us and n8n. Any suggestions very, very welcome!

1 Like

same. I found it very useful to dynamically give the credentials

Dynamic per‑user Google Calendar OAuth in n8n — is it possible in 2025?

Hi all,

I’m building a B2B booking system in n8n: each of our sub‑company clients must ā€œConnect with Googleā€ so that when their end‑customers book appointments via VAPI, the events go into the correct Google Calendar. I already have:

  1. An n8n Form that collects company info plus a ā€œConnect with Googleā€ redirect.
  2. A separate workflow that, given valid OAuth credentials, can check availability and create events on Google Calendar.

But I’m stuck on the OAuth piece: how do I let each sub‑company click a ā€œConnect with Googleā€ button (outside of n8n) and then pass their tokens into n8n so that our single ā€œappointmentā€ workflow uses the right credentials dynamically?

I found these two community quotes from 2021:

My questions in 2025 are:

  1. Is dynamic per‑workflow OAuth credential assignment still ā€œunder development,ā€ or is there now a supported pattern?
  2. If it’s possible today, what’s the recommended end‑to‑end flow? (Redirect URIs, webhook callbacks, API calls to create credentials, etc.)
  3. If it’s not yet supported natively, what’s the best community‑approved workaround?

Any up‑to‑date examples, code snippets, or pointers to n8n roadmap items would be hugely appreciated. Thanks in advance!

Built small, dedicated external service. This external service handles the user-facing OAuth flow and secure token storage, allowing n8n workflow to dynamically fetch and use these tokens via HTTP Requests.

1 Like

How do you pass the tokens to the running workflows? They don’t seem to accept anything other then the ID of a pre-existing credential.

Hey came across your comment as I was looking for a way to do exactly what you describe. Can we now have dynymic OAuth credentials? Thanks, Julien

I’m not sure how he did it, but I got the refresh token too — so we can use it to refresh the access token.

Honestly I don’t remember how I did it or if that actually worked. It’s been a while since then :slight_smile: Hope you find a solution!