So, you've got your own n8n instance up and running. You're ready to build some epic workflows, connect all the things, and basically give yourself automation superpowers. But then you hit a snag: you try to connect a Google service like Sheets or Drive, and it asks you to set up something called "OAuth2."
If you're feeling a little lost, you're not alone. For self-hosted n8n, setting up your own Google OAuth2 credentials is a necessary step, and let's be real, it can feel a bit complicated. But don't worry, we're going to walk through it together, step-by-step.
First off, what even is OAuth 2.0?
Think of OAuth 2.0 as a secure key card system for the internet. Instead of giving an application (like n8n) your actual username and password for another service (like Google), you give it a special, limited-access key card.
This key card says, "This app is allowed to do these specific things on my behalf, and nothing more." You can revoke this access at any time without changing your main password. It's the standard for secure authorization, which is why so many services use it.
Okay, but why is it so complicated? Why not just one API token?
That's the million-dollar question! A simple API token is like a master key. Anyone who has it can access everything. For a cloud service you pay for, the company handles the security of that key.
But since you're self-hosting n8n, you are the one in control. The complexity is actually a good thing—it's what keeps your data secure. You're telling Google, "Hey, it's me, the owner of this specific n8n instance. I want to grant it permission to access my stuff." Google needs to verify that it's really you and your app, which involves this multi-step handshake.
Ready to get it done? Let's dive in.
The Step-by-Step Guide to Google OAuth2 Setup
Step 1: Create or Select a Google Cloud Project
This is our command center for managing all of Google's services.
- Head over to the Google Cloud Console: https://console.cloud.google.com
- Log in with your Google account. If you're new, you might need to add Credit Card and agree to some terms.
- At the top of the page, next to the Google Cloud logo, you'll see a project dropdown. Click on it and then click "New Project".
- Give your project a name. Something memorable like "My-n8n-Workflows" is perfect.
- Click "Create". It might take a moment, but you'll be redirected to your new project dashboard. Make sure your new project name is selected in the top dropdown.
Step 2: Enable the APIs You Need
Now we need to tell Google which services our n8n instance will be allowed to talk to. Think of this as activating the right phone lines.
- In the search bar at the top, type the name of the API you want to use, for example, "Google Docs API".
- Select it from the results and click the big blue "Enable" button.
- Repeat this process for every Google service you plan to automate. Common ones include:
- Google Drive API
- Gmail API
- Google Calendar API
- Google Sheet API
Step 3: Configure Your OAuth Consent Screen
- In the top search bar, search for "OAuth consent screen" and select it.
- App Information:
- App name: Give it a name, like "My n8n Automation Hub".
- User support email: Select your email address.
- Developer contact information: Enter your email address again.
- You'll be asked for a User Type:
- Internal: Only for users within your Google Workspace organization. (If you're using a standard
@gmail.com
account, you can't select this). - External: For any Google user. This is the one you'll probably need. Select it and click "Create".
- Internal: Only for users within your Google Workspace organization. (If you're using a standard
- Click "Save and Continue" through the "Scopes" and "Optional Info" pages for now. We don't need to add anything there.
- On the "Test users" page, click "+ Add Users". Add the Google email address(es) you'll be using to log in and authenticate with n8n. You must add your own email here! If you plan to share your n8n with friends, you'll need to add their emails here too.
- Click "Save and Continue" and then "Back to Dashboard".
Step 4: Create Your Credentials (The Keys!)
This is the final step where we generate the actual Client ID and Secret that n8n needs.
- From the left-hand menu, navigate to the "Credentials" tab.
- Click "+ Create Credentials" at the top and select "OAuth client ID".
- For "Application type", select "Web application".
- Give it a Name for your own reference, like "n8n Web Client".
- Now, the important part: Authorized redirect URIs.
- Open a new tab and go to your n8n instance.
- Click on "Credentials" in the left sidebar, then "Create new".
- Search for and select the Google credential you want to create (e.g., "Google Sheets OAuth2 API").
- A modal will pop up. Look for the "Redirect URL". It will look something like
https://your-n8n-domain.com/rest/oauth2-credential/callback
. Copy this URL.
- Go back to the Google Cloud Console and under "Authorized redirect URIs", click "+ Add URI".
- Paste the Redirect URL you copied from n8n.
- Click "Create".
- A box will appear with your Client ID and Client Secret. Success!
Step 5: Connect n8n to Google
We have the keys, now we just need to give them to n8n.
- Copy the Client ID from Google Cloud.
- Go to your n8n credential setup screen and paste it into the "Client ID" field.
- Go back to Google Cloud and copy the Client Secret.
- Paste it into the "Client Secret" field in n8n.
- Click the "Sign in with Google" button.
- A Google login window will pop up. Choose the account you added as a "Test User". You might see a "Google hasn't verified this app" warning—this is normal for apps in testing mode. Click "Continue" to proceed.
- Grant the permissions.
And... that's it! Your credential should now be saved and active in n8n.
Wooohooo! You've successfully navigated the maze of Google OAuth2. It's a bit of a journey, but now you have a secure, robust connection ready to power all of your future automations. Go build something amazing!