How to Connect n8n to Google Drive
Learn how to connect n8n to Google Drive by setting up Google Cloud Platform credentials and using the Google Drive node to access your files.
How to Connect n8n to Google Drive
To access your Google Drive files from n8n, you need to set up a Google credential using the Google Cloud Platform. This tutorial will guide you through creating a Google Cloud project, configuring OAuth 2.0 credentials, and connecting your Google Drive to an n8n workflow.
Prerequisites
- An n8n workflow (a manual trigger is fine for testing).
- A Google Account to create a Google Cloud project.
Step 1: Create a Google Cloud Project
First, you need a Google Cloud project to manage APIs and credentials.
- Go to the Google Cloud Console.
- If prompted, sign in with your Google account and agree to the terms of service.
- In the top-left corner, click the project selection dropdown and then click "New Project".
- Give your project a name, for example,
n8n-google-drive-integration. - Click "Create".
- Once the project is created, make sure it is selected in the project dropdown.
Step 2: Configure the OAuth Consent Screen
Before creating credentials, you must configure the consent screen, which tells users who is requesting access to their data.
- In the Google Cloud Console, navigate to the navigation menu (hamburger icon) and go to "APIs & Services" > "OAuth consent screen".
- Select the "External" user type, as this is for a testing application. Click "Create".
- Fill in the required information:
- App name:
n8n Google Drive Connection - User support email: Select your email address.
- Developer contact information: Enter your email address.
- App name:
- Click "Save and Continue" through the "Scopes" and "Optional info" steps.
- On the "Test users" step, click "+ Add Users".
- Enter the email address of the Google account you'll use to connect to Google Drive. This is crucial for avoiding access errors later.
- Click "Add", and then "Save and Continue".
- Review the summary and click "Back to Dashboard".
Step 3: Create OAuth 2.0 Credentials
Now you can create the Client ID and Client Secret that n8n needs.
- Go to "APIs & Services" > "Credentials".
- Click "+ Create Credentials" and select "OAuth client ID".
- For "Application type", select "Web application".
- Give it a name, such as
n8n Web Client. - Under "Authorized redirect URIs", you need to add the URI from n8n.
- In your n8n workflow, add a Google Drive node.
- In the "Credential" field, select "Create New".
- You will see a field for "OAuth Redirect URL". Click to copy it.
- Go back to the Google Cloud Console and paste this URL into the "Authorized redirect URIs" field.
- Click "Create". A window will pop up with your Client ID and Client Secret. Keep this window open.
⚠️ Important: Treat your Client ID and Secret like passwords. Do not share them publicly.
Step 4: Add and Configure the Google Drive Node in n8n
Now, let's go back to your n8n workflow to finalize the connection.
4.1 Create Google Drive Credentials
- In the Google Drive node, ensure the credential type is OAuth2.
- Copy the Client ID from the Google Cloud Platform and paste it into the "Client ID" field in n8n.
- Copy the Client Secret and paste it into the "Client Secret" field in n8n.
- Click "Save".
4.2 Authenticate Your Account
- After saving, a "Sign in with Google" button will appear at the bottom of the node settings. Click it.
- A new window will open. Choose the Google account you added as a test user.
- You might see a warning that "Google hasn't verified this app." This is expected for test applications. Click "Continue" to proceed.
- Grant the necessary permissions for n8n to access your Google Drive files.
- If successful, the window will close, and you'll see a "Connection tested successfully" message in n8n.
Step 5: Enable the Google Drive API
You might encounter one final error when you try to use the node.
- In the Google Drive node, try to select a file. You may see an error stating
Google Drive API has not been used in project ... before or it is disabled. - The error message includes a link to enable the API. Click this link.
- It will take you to the Google Drive API page for your project. Click the "Enable" button.
- Wait a moment for the API to be enabled.
Step 6: Access Your Files
Go back to your n8n workflow. You may need to close and reopen the Google Drive node to refresh it.
- Now, when you click the file dropdown, it should successfully list the files and folders from your Google Drive.
- Select an operation (e.g., Download a File) and choose a file.
- Click "Execute Node".
You should now see the file data from your Google Drive pulled into n8n. You have successfully connected n8n to Google Drive and can now automate file operations like uploading, downloading, and searching.