Getting OAuth2 for my remote client

My automation contains Gmail email sending, and it should be sent from my client’s Gmail as the sender. How do I add OAuth authentication for my client’s Gmail?
When I try to create a new OAuth2 credential, a popup window appears to log in with Google, but I don’t have my client’s credentials. I’ve passed them the link from that popup window but it doesn’t work.

How do I configure the sender remotely (without the client having to come to my physical computer) and without sharing credentials between us?

Hey @Daniela_Akerman, while you wait for a response, here are some things that might help:

Suggested resources

Automatically matched to your question.

Docs:

Forum:

@Hovec, @BramKn, @mje - you’ve helped with similar issues before, can you take a look?

Automatically suggested by n8n’s community bot. It’s a pilot - please share feedback here.

For OAuth2 to work remotely, your n8n instance must be accessible via a public URL (e.g., https://n8n.yourdomain.com).

  1. Ensure n8n is public: If you are self-hosting, ensure you have configured the WEBHOOK_URL environment variable to your public domain.
  2. Start the process: In your n8n credential settings for Gmail, click the “Connect my account” (or similar) button.
  3. Copy the Redirect URL: When the Google login popup opens, do not just copy the URL from the address bar while it’s on the “Sign in” page. Instead, wait until the popup is active, then copy the entire URL from the address bar of that popup window.
  4. Send to Client: Send that specific URL to your client.
  5. Client Action: The client opens the link, logs into their Gmail, and clicks “Allow.”
  6. The Handshake: Because your n8n instance is on a public URL, the client’s browser will successfully redirect them back to your n8n instance with the authorization code. Your n8n will automatically “catch” this code and finish the setup.

Note: If you cannot host n8n publicly, you can temporarily use a tool like ngrok or Cloudflare Tunnel to create a secure, public URL for your local n8n instance just for this authentication step.

If the client’s IT policy makes OAuth2 too difficult, or if you cannot move to a public URL, you can use the IMAP/SMTP method instead of the Gmail node’s OAuth2.

  1. Client Task: Ask the client to generate an “App Password” in their Google Account settings (requires 2-Step Verification to be ON).
  2. Your Task: In n8n, instead of using the “Gmail” node with OAuth2, use the “Send Email” node configured with SMTP settings:
    • Host: smtp.gmail.com
    • Port: 465 (SSL) or 587 (STARTTLS)
    • User: The client’s Gmail address.
    • Password: The 16-character App Password they generated.
  3. Benefit: This bypasses the OAuth redirect entirely and works perfectly on localhost.

Hi @Daniela_Akerman Welcome!
Assuming you built your own OAuth client in the Google Cloud Console, your client’s Google account has to be allowed by that app before the consent link does anything for them. An External app starts in Testing mode, where only addresses on the test user list can finish the flow and every other account gets an access denied screen.
Open Google Auth Platform > Audience in the Cloud Console and set Publishing status to In production, then send them the link again. Adding their address under Test users clears the block too, but Testing expires the token after 7 days, so the credential would die a week after handover.