Using expression in the impersonate field of the Google Service Account credential fails

Describe the issue/error/question

Hi,

I am using the Gmail node, with Service account and impersonation. It works fine.
But if i use an expression to set the impersonate user value, it stays on the first row value and doesn’t iterate.

May this be a bug ? Is there something I am missing here ?

Share the output returned by the last node

Gmail previous node outputs something like this

[
  { address: [email protected] },
  { address: [email protected] }
]  

I have set the impersonate user value, in service account credential to :

{{$json["address"]}}

When executing the Gmail node, with this credential settings, it retrives messages twice on the first address, instead of iterating on both.

I am stuck on this one. Help will be really appreciate. By the way, great piece of software I am really enjoying it.

Information on your n8n setup

  • n8n version: n8n 0.185.0
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]: own
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: npm

Hi @Maximilien, welcome to the community!

Credentials are only loaded once, no matter how many items you’re passing on to the node. So if you want to use different credentials for each item, my suggestion would be to split up your data in batches (with a size of 1 item per batch) using the Split In Batches node.

A generic workflow demonstrating the idea would be this one:

The credentials contain an expression of {{$json["address"]}}, reading the address field:

image

When running the workflow you can see that each request uses different credentials and sends them to my webhook.site URL:

Hope this helps!

Hello @MutedJam,

Thanks for the quick and excellent response. That’s what I intended to do. And you saved me precious time.

It now works as expected.

Cheers.

1 Like

Hello @Maximilien,
Do you mind sharing an example of this part of your workflow? I’m intending to do something very similar but I can’t seem to get through it.
Thanks.

Hi Loan_J,
As requested an exemple workflow.
Hope this will help.

Regards.

2 Likes

Thanks a lot for this, it helps!

1 Like