Google Gmail/Tasks API and IMAP Issues - "Invalid Credentials (Failure)" and Reconnect Loop in n8n

Hello, I’m experiencing persistent issues with Google Gmail, Tasks API, and IMAP integrations in n8n. The workflows initially connect successfully, but they quickly show “Reconnect” or fail with the error “Invalid credentials (Failure).” Here are the details:

Problem Description:

  1. Gmail API (OAuth2):
  • I set up the Gmail node with a new OAuth2 credential.
  • Clicking “Connect” successfully authenticates with Google, but immediately after, it shows “Reconnect.”
  • I’ve tested this with both personal and work Google accounts, and the issue is consistent.
  1. Google Tasks API:
  • The same behavior occurs: the connection is established momentarily, but then I’m prompted to reconnect.
  1. IMAP Integration:
  • I configured IMAP with an app-specific password (for Gmail) and enabled IMAP access in the account settings.
  • However, the error persists:
    “Invalid credentials (Failure)”

Error Details:

Example from IMAP:

{
“errorMessage”: “Invalid credentials (Failure)”,
“errorDetails”: {},
“n8nDetails”: {
“n8nVersion”: “1.74.3 (Cloud)”,
“binaryDataMode”: “filesystem”,
“stackTrace”: [
“Error: Invalid credentials (Failure)”,
" at Connection._resTagged (/usr/local/lib/node_modules/n8n/node_modules/imap/lib/Connection.js:1502:11)“,
" at Parser. (/usr/local/lib/node_modules/n8n/node_modules/imap/lib/Connection.js:194:10)”,
" at Parser.emit (node:events:518:28)“,
" at Parser._resTagged (/usr/local/lib/node_modules/n8n/node_modules/imap/lib/Parser.js:175:10)”,
" at Parser._parse (/usr/local/lib/node_modules/n8n/node_modules/imap/lib/Parser.js:139:16)“,
" at Parser._tryread (/usr/local/lib/node_modules/n8n/node_modules/imap/lib/Parser.js:82:15)”,
" at TLSSocket.Parser.cbReadable (/usr/local/lib/node_modules/n8n/node_modules/imap/lib/Parser.js:53:12)“,
" at TLSSocket.emit (node:events:518:28)”,
" at emitReadable
(node:internal/streams/readable:834:12)“,
" at processTicksAndRejections (node:internal/process/task_queues:81:21)”
]
}
}

Example from Gmail API (OAuth2):

{
“errorMessage”: “Unable to sign without access token (item 0)”,
“n8nDetails”: {
“nodeName”: “Gmail”,
“nodeType”: “n8n-nodes-base.gmail”,
“operation”: “getAll”,
“itemIndex”: 0
}
}

Steps Taken:

  1. Google Cloud Configuration:
  1. IMAP Setup:
  • Enabled IMAP access in Gmail settings.
  • Generated an app-specific password (for accounts with 2FA).
  • Verified that IMAP works in other clients (e.g., Thunderbird).
  1. Testing in n8n:
  • Created new credentials for Gmail, Tasks, and IMAP in n8n.
  • Authentication succeeds momentarily, but:
    Gmail and Tasks prompt to reconnect after a few seconds.
    IMAP fails with “Invalid credentials (Failure).”
  1. Account Variations:
  • Tested with two different accounts (personal and work).
  • The same behavior persists across both accounts.

Environment:

n8n Version: 1.74.3 (Cloud)
Integration Nodes Affected: Gmail API, Tasks API, IMAP
Google Accounts: Personal Gmail and Google Workspace accounts
Other Clients: IMAP works in Thunderbird with the same credentials.

Questions:

  1. Is this issue related to n8n’s token management for OAuth2 (e.g., refresh tokens not working properly)?
  2. Are there known bugs in the Gmail, Tasks, or IMAP nodes in the current n8n version?
  3. Is there a recommended workaround to avoid the “Reconnect” issue with Google APIs in n8n?

Attachments:

If additional screenshots or examples are needed, I can provide them.

Thank you for your help!

1 Like

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.