For n8n to read and write a Google Sheets spreadsheet it needs a credential proving to Google that n8n is allowed to touch that sheet. There are two roads: sign in with a Google account (OAuth), or use a service account, which is a robot account you share the sheet with. Google and n8n keep changing their screens, so this article explains the logic and leaves the clicks to the official documentation of both.
Which road to take
|
Google account (OAuth) |
Service account |
| How it works |
n8n asks Google for permission on behalf of a person. |
A robot account with an address of its own, added to the sheet like a collaborator. |
| Access |
Everything that person can see, as far as the permission given. |
Only the sheets you share with it. |
| Needs n8n on HTTPS |
Yes: Google sends the person back to an address on your n8n. |
No. |
| If the person leaves the company |
The workflow stops, because the account is theirs. |
Nothing changes. |
For a company, the service account is the safer and steadier choice. OAuth is quicker to set up for a personal trial.
The flow, start to finish
| 1 |
Have a project in Google Cloud and enable the Google Sheets API in it. Google may also ask for the Drive one, so n8n can list the sheets: if an error says an API is not enabled, this is why.
|
|
| 2 |
Create the credential. For OAuth, create client credentials at Google and enter the ID and secret in n8n. n8n shows you the redirect address Google has to accept; copy it exactly as it is. That is why n8n needs HTTPS and must know its own address, as in n8n behind HTTPS on your own domain.
|
|
| 3 |
For a service account, Google gives you a file with the key. n8n asks for the account address and the key. Then open the sheet and share it with the service account address, the way you would with a person.
|
|
| 4 |
Prepare the sheet. The first row holds the headers; n8n uses them as column names. Do not rename the headers after building the workflow, or it stops finding them.
|
|
| 5 |
Choose the operation in the node: read rows, append a row, or update a row that has a given value in a column. To update, pick a column with unique values (an order number, say).
|
|
| 6 |
Test on a scratch sheet before pointing at the real one.
|
|
|
“It worked, and then it stopped”. With OAuth, if the app at Google stays in testing mode, the permission can expire after a while and the workflow starts failing though nobody touched anything. Google explains the rules for the app status in its documentation; look there first. A service account does not have this problem.
|
Care with the sheet
| Situation |
What to do |
| Many rows at once |
Send in batches instead of one call per row. Google limits requests per minute. |
| Two executions at the same time |
They may write to the same row. Avoid it, or write to a separate sheet and merge afterwards. |
| Sensitive data |
A sheet is easy to share by mistake. Limit who can see it. |
|
Also write the date and the source on every row the workflow adds. When something looks odd, you know where it came from.
|
RECOMMENDED PRODUCT Web hosting with cPanel Domain and SSL included, daily backups and the panel you already know. from $6.59/mo (3-year plan, with coupon) See plans |