Step-by-step guide to integrate n8n with Google Sheets using OAuth authentication. This tutorial will walk you through the process of setting up Google Cloud, configuring OAuth credentials, and connecting them to n8n effectively. The process ensures a secure and seamless integration for automating your Google Sheets workflows.
Prerequisites for Setting Up n8n with Google Sheets
Before we begin, ensure you have the following tools and accounts ready:
prerequisites
- Access to Google Cloud Console.
- An active n8n instance (self-hosted or cloud-based) that is accessible.
- A Google account with access to Google Sheets.
- A basic understanding of OAuth concepts.
Steps to Configure Google Cloud Console for Google Sheets API
To start using the Google Sheets API, you'll need to configure your Google Cloud Console project.
steps
- Open Google Cloud Console and log in with your Google account.
- Click Select a project in the top navigation, then click New project. Provide a name for the project and hit Create.
- Once the project is created, ensure it is selected.
- In the search bar, type Google Sheets API and click on it. Hit the Enable button for the API.
- Navigate to the OAuth consent screen in the left-hand menu.
- Select External for User Type and click Create.
- Fill in basic information such as the App Name and Support Email. Add your email address and save changes. (Adding a logo or domain is optional.)
- Under Scopes, select all necessary scopes (recommended for full API access). Click Save and continue.
- Add your Google account email as a Test user and save.
Generating and Configuring OAuth Credentials
To enable n8n to authenticate with Google Sheets via OAuth, you must create credentials in Google Cloud.
steps
- Go back to the Google Cloud Console, navigate to the Credentials section, and select Create credentials > OAuth client ID.
- For Application type, choose Web Application and enter a name (e.g., "n8n Integration").
- Add your OAuth Redirect URL from n8n into the Authorized redirect URIs section. You’ll find this URL in n8n under Settings > Add Credentials > Sheets OAuth2.
- Hit Create and copy the generated Client ID and Client Secret. You'll need these for n8n.
Configuring n8n for Google Sheets Integration
Now that we have the Client ID and Secret, configure n8n to use these credentials for authorizing with Google Sheets.
steps
- Open n8n and navigate to Credentials in the settings.
- Click Add Credential, choose Google Sheets OAuth2, and select Create New.
- Paste the Client ID and Client Secret you copied earlier into the respective fields.
- Save the credential and click Connect to initiate the OAuth process.
- Log in with your Google account and grant permissions to the application. If Google warns you that the app is not verified, click Continue (this is expected for new or unverified apps).
- Once completed, the credential will be marked as connected and can be used in your workflows.
Testing the Integration to Verify Connection
To ensure everything is working as expected, test the connection by creating a Google Sheets workflow in n8n.
steps
- Create a new workflow in n8n and add a Manual Trigger node.
- Add a Google Sheets node to your workflow. Configure it to use the credential you just created.
- Set the node to Create Spreadsheet and provide a name for the new spreadsheet (e.g., "Test Sheet").
- Execute the workflow. Verify that the spreadsheet is successfully created in your Google Drive.
Tips for Handling Common Mistakes
Integration issues can occur, especially with OAuth setup. Follow these tips to avoid common pitfalls:
FAQ
Why is my app marked as "unverified" by Google?
Google flags new apps that haven’t gone through the verification process as untrusted. This is normal for newly created OAuth applications. You can proceed past the warning if you are sure of your setup.
How do I find the OAuth Redirect URL in n8n?
In n8n, go to the Credentials tab, click on Add Credential, and select Sheets OAuth2. The required Redirect URL will be displayed on this screen.
What should I do if my workflow cannot access Google Sheets?
Check if the OAuth credential in n8n is correctly configured and connected. Ensure the proper permissions are granted to the app during the OAuth setup, and that the Google Sheets API is enabled in your Google Cloud project.