How to Generate an OAuth 2.0 Client ID for Your Extension
This guide will walk you through creating the necessary credentials in the Google Cloud Console to allow your extension to use the Gmail API.
Step 1: Get Your Extension's ID
Before you start, you need the unique ID that Chrome has assigned to your extension.
Open Chrome and go to the extensions page:
chrome://extensions
Make sure "Developer mode" is enabled (toggle in the top-right).
Find your "Gmail AI Assistant" extension.
Copy the ID (it will be a long string of letters, like
aeblfdbeijboljppnpclcglclpdemjga
). Keep this handy.
Step 2: Create a Google Cloud Project
Go to the Google Cloud Console.
Click the project selector dropdown at the top of the page and click "New Project".
Give your project a name (e.g., "Gmail AI Assistant Project") and click "Create".
Step 3: Enable the Gmail API
Make sure your new project is selected.
In the search bar at the top, type "Gmail API" and select it from the results.
Click the "Enable" button.
Step 4: Configure the OAuth Consent Screen
This is the screen users will see when asked for permission.
From the navigation menu (☰), go to APIs & Services > OAuth consent screen.
Choose "External" for the User Type and click "Create".
Fill in the required fields:
App name: "Gmail AI Assistant"
User support email: Your email address
Developer contact information: Your email address
Click "Save and Continue" through the "Scopes" and "Test users" sections. You don't need to add anything here for now.
On the Summary page, click "Back to Dashboard".
Step 5: Create the OAuth 2.0 Client ID
This is the final step to get your key.
From the navigation menu, go to APIs & Services > Credentials.
Click "+ Create Credentials" at the top and select "OAuth client ID".
For "Application type", select "Chrome App".
Give it a name (e.g., "Gmail Extension Credentials").
In the "Application ID" field, paste the Extension ID you copied in Step 1.
Click "Create".
Step 6: Update Your manifest.json
A popup will appear showing you your Client ID. Copy this entire value.
Open your local
manifest.json
file.Replace the placeholder
"YOUR_CLIENT_ID.apps.googleusercontent.com"
with the Client ID you just copied.Save the
manifest.json
file.Go back to
chrome://extensions
, find your extension, and click the "Reload" button.
Your extension is now fully configured! The action buttons should now trigger the Google authentication flow the first time you use them.
Yes I am.
This is automatable I am sure
If I was going to give this to my husband or a friend as a useful extension, i wouldn't want them to have to go through a complicated set of steps that i would probably have to physically be there to help them through. So we are going to need to automate this as a next steps to the next step
You've hit on a crucial point for making this a real, shareable product. You are absolutely right that a non-technical user shouldn't have to go through a complex setup process.
The manual setup is a necessary step for a developer version, but it's not how a finished, public extension works.
Let's break this down into two parts:
- Getting it working for you now: I'll provide a step-by-step guide for you to generate your own Client ID. This will make your version of the extension fully functional.
- How it gets automated for friends and family: I'll explain the standard process for publishing an extension, which is how the setup becomes a simple, one-click process for everyone else.
First, here is the guide to get your developer version running.
The "Automation" for Other Users
Now, to your point about making this easy for your husband or a friend. The guide above is only for development. To make it a shareable product, the process is:
- You (the developer) do the setup once: You follow the guide above to create one official Client ID for the production version of the extension.
- Submit for Verification: You publish the extension to the Chrome Web Store. As part of this process, because you are asking for sensitive permissions (to read and modify Gmail), Google will conduct a security review of your extension.
- One-Click Install for Users: Once your extension is verified and published, anyone can install it from the Chrome Web Store. When they use a feature for the first time, they will see the standard Google "This app wants permission to..." screen. They just click "Allow," and they're done. They never have to see the Cloud Console or handle a Client ID.
So, the "automation" you're looking for is actually the standard publishing and verification process managed by Google.
Finally, I noticed I had made a small error in the background.js
file, which I have now corrected in the main Canvas artifact. The action buttons should now work correctly after you've updated your Client ID.
Comments