Upload to Google Drive node not working with Service Account - Keep getting 403 error

Describe the problem/error/question

Google Drive Upload not working with Service Account. I’ve gone through all the immediate fixes I’ve found.
The private key is pasted in exactly as needed (although when I go in to check on it, I get the “n8n BLANK VALUE” key for some reason)
The email of the service account is added as an editor to the drive folder.

I want to use a Service Account instead of an OAuth because I don’t want to have to reset it every few days - this needs to run 24/7 essentially.

What is the error message (if any)?

403

Please share your workflow

Share the output returned by the last node

{
“errorMessage”: “Request failed with status code 403”,
“errorDetails”: {},
“n8nDetails”: {
“n8nVersion”: “1.112.4 (Cloud)”,
“binaryDataMode”: “filesystem”,
“stackTrace”: [
“AxiosError: Request failed with status code 403”,
" at settle (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/axios/lib/core/settle.js:19:12)“,
" at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/axios/lib/adapters/http.js:617:11)”,
" at IncomingMessage.emit (node:events:531:35)“,
" at endReadableNT (node:internal/streams/readable:1698:12)”,
" at processTicksAndRejections (node:internal/process/task_queues:90:21)“,
" at Axios.request (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/axios/lib/core/Axios.js:45:41)”,
" at processTicksAndRejections (node:internal/process/task_queues:105:5)“,
" at invokeAxios (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_08b575bec2313d5d8a4cc75358971443/node_modules/n8n-core/src/execution-engine/node-execution-context/utils/request-helper-functions.ts:313:10)”,
" at Object.httpRequest (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_08b575bec2313d5d8a4cc75358971443/node_modules/n8n-core/src/execution-engine/node-execution-context/utils/request-helper-functions.ts:898:17)“,
" at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_afd197edb2c1f848eae21a96a97fab23/node_modules/n8n-nodes-base/nodes/Google/Drive/v2/actions/file/upload.operation.ts:161:22”,
" at processInChunks (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_afd197edb2c1f848eae21a96a97fab23/node_modules/n8n-nodes-base/nodes/Google/Drive/v2/helpers/utils.ts:157:3)“,
" at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_afd197edb2c1f848eae21a96a97fab23/node_modules/n8n-nodes-base/nodes/Google/Drive/v2/actions/file/upload.operation.ts:159:3)”,
" at ExecuteContext.router (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_afd197edb2c1f848eae21a96a97fab23/node_modules/n8n-nodes-base/nodes/Google/Drive/v2/actions/router.ts:29:26)“,
" at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_afd197edb2c1f848eae21a96a97fab23/node_modules/n8n-nodes-base/nodes/Google/Drive/v2/GoogleDriveV2.node.ts:25:10)”,
" at WorkflowExecute.executeNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_08b575bec2313d5d8a4cc75358971443/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1254:8)“,
" at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_08b575bec2313d5d8a4cc75358971443/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1428:11)”,
" at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_08b575bec2313d5d8a4cc75358971443/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1761:27",
" at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_08b575bec2313d5d8a4cc75358971443/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:2338:11"
]
}
}

Information on your n8n setup

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

Btw, you can simply set your app to In Production in Google Cloud Console, then you can also use OAuth without expiration. It doesn’t require you to actually verify the app officially, and you won’t need to add any emails as testers.

If sticking with the service acc, I would double check if the scopes added cover what you need to do in Drive too: Choose Google Drive API scopes  |  Google for Developers

I’ve added it multiple times, did not work.

So I tried this, and when I go to verify the credentials, I get this window:

Try to generate a new secret and use it in n8n, does it get through? Also, you will need to click the Sign in with Google button and go through the steps again

Ok, that seemed to have worked, thank you! So now i don’t need to do any reauthentication?

Yes, now it shouldn’t expire. Great. Would appreciate if you mark this as Solution :slight_smile: :

1 Like

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