Learn how to create your own Google OAuth credentials (Client ID & Client Secret) in the Google Cloud Console and use them as a custom OAuth provider on AIBotBuilder.
AIBotBuilder provides built-in system OAuth providers for popular Google Workspace APIs (Gmail, Drive, Calendar, Sheets, Tasks, and more). However, you may want to use your own credentials to get higher API quotas, use your own branding on the consent screen, or maintain full control over your OAuth configuration.
You don't need to create your own credentials if the system providers are working fine for you. Custom credentials are useful when:
Before you begin, make sure you have:
Google Cloud offers a generous free tier. Creating a project and generating OAuth credentials is completely free. You only pay if you exceed the free-tier API usage limits, which is unlikely for typical bot usage.
A Google Cloud project acts as a container for all your API credentials and settings.
Open console.cloud.google.com and sign in with your Google account.
Click the project dropdown at the top of the page (next to "Google Cloud"), then click "New Project".
My AIBotBuilder OAuthWait a few seconds for the project to be provisioned. Once created, make sure it's selected as the active project in the top dropdown.
You need to explicitly enable each Google API your bot commands will use. Here's how:
Here are the APIs you should enable based on which Google services your bot commands use:
Send emails, read inbox, manage labels
gmail.googleapis.com
Upload, download, share files
drive.googleapis.com
Create events, manage calendars
calendar-json.googleapis.com
Read/write spreadsheet data
sheets.googleapis.com
Create and manage task lists
tasks.googleapis.com
Create and edit documents
docs.googleapis.com
Create and edit presentations
slides.googleapis.com
Access and manage photos
photoslibrary.googleapis.com
Only enable the APIs you actually need. You can always come back and enable more later. Enabling an API doesn't cost anything — you're only charged for actual API usage beyond free quotas.
The OAuth consent screen is what users see when they authorize your bot to access their Google account. You must configure this before creating credentials.
Go to APIs & Services → OAuth consent screen in the left sidebar.
Select the user type for your app:
Available to any Google account. This is the right choice if your bot serves users outside your organization. While in testing mode, only users you add as test users can authorize.
Only available if you have a Google Workspace account. Restricts access to users within your organization only.
Complete the required fields:
My AIBotBuildertelegrambotbuilder.comClick "Add or Remove Scopes" and add the scopes for the APIs you enabled. See the Scopes Reference section below for common scopes.
Note: The scopes you add here must match the scopes configured in your custom OAuth provider on AIBotBuilder. If they don't match, the authorization will fail.
While your app is in "Testing" mode, only users you explicitly add can use it. Click "Add Users" and enter the Gmail addresses of the people who will be using your bot commands.
Important: You can add up to 100 test users. These are the Google accounts that will be able to authorize your bot via OAuth while the app is in testing mode. Remember to add your own email address!
Review the summary and click "Back to Dashboard". Your consent screen is now configured.
Now you'll generate the Client ID and Client Secret that you'll use in AIBotBuilder.
Navigate to APIs & Services → Credentials in the left sidebar.
Click "+ Create Credentials" at the top, then select "OAuth client ID".
Fill in the following settings:
Web applicationAIBotBuilder OAuthhttps://app.telegrambotbuilder.com/api/oauth/callback
🚨 Critical: The redirect URI must be exactly https://app.telegrambotbuilder.com/api/oauth/callback. If it doesn't match exactly, OAuth authorization will fail with a "redirect_uri_mismatch" error.
Click "Create". A dialog will appear showing your credentials:
Client ID:
123456789012-abcdefghijklmnop.apps.googleusercontent.com
Client Secret:
GOCSPX-AbCdEfGhIjKlMnOpQrStUvWxYz
⚠️ Important: Copy and save both values securely. The Client Secret will only be shown once in this dialog. You can always access it later from the Credentials page, but it's easier to copy it now.
When creating a custom OAuth provider on AIBotBuilder, you need to specify the correct scope for the Google API you're targeting. Here are the most commonly used scopes:
| Service | Scope URL | Access Level |
|---|---|---|
| 📧 Gmail | https://mail.google.com/ |
Full access (read, send, delete) |
| 📧 Gmail (Send only) | https://www.googleapis.com/auth/gmail.send |
Send emails only |
| 📧 Gmail (Read only) | https://www.googleapis.com/auth/gmail.readonly |
Read inbox only |
| 📁 Google Drive | https://www.googleapis.com/auth/drive.file |
Files created/opened by the app |
| 📁 Google Drive (Full) | https://www.googleapis.com/auth/drive |
Full access to all files |
| 📅 Google Calendar | https://www.googleapis.com/auth/calendar |
Full calendar access |
| 📊 Google Sheets | https://www.googleapis.com/auth/spreadsheets |
Full spreadsheets access |
| ✅ Google Tasks | https://www.googleapis.com/auth/tasks |
Full tasks access |
| 📄 Google Docs | https://www.googleapis.com/auth/documents |
Full documents access |
| 📽️ Google Slides | https://www.googleapis.com/auth/presentations |
Full presentations access |
| 📷 Google Photos | https://www.googleapis.com/auth/photoslibrary |
Full photos library access |
| 🔍 Custom Search | https://www.googleapis.com/auth/cse |
Google Custom Search |
| 📊 Google Analytics | https://www.googleapis.com/auth/analytics.readonly |
Read analytics data |
| 🎓 Google Classroom | https://www.googleapis.com/auth/classroom.courses |
Access courses and assignments |
If a single command needs access to multiple Google services, you can combine scopes by separating them with commas. For example, to access both Calendar and Tasks:
https://www.googleapis.com/auth/calendar,https://www.googleapis.com/auth/tasks
Now that you have your Client ID and Client Secret, let's create a custom OAuth provider on AIBotBuilder.
Log in to AIBotBuilder and navigate to the OAuth page from the main menu.
Click the "Custom OAuth Providers" tab, then click "Create Custom Provider".
Here's an example for Google Calendar (adapt for your target API):
Click "Create" to save your custom provider. It will appear in your custom providers list.
All Google Workspace APIs share the same Auth URL and Token URL. Only the Scopes and API Base URL differ:
https://accounts.google.com/o/oauth2/authhttps://oauth2.googleapis.com/token| Service | API Base URL |
|---|---|
| Gmail | https://gmail.googleapis.com |
| Google Drive | https://www.googleapis.com/drive/v3 |
| Google Calendar | https://www.googleapis.com/calendar/v3 |
| Google Sheets | https://sheets.googleapis.com/v4 |
| Google Tasks | https://tasks.googleapis.com/v1 |
| Google Docs | https://docs.googleapis.com/v1 |
| Google Slides | https://slides.googleapis.com/v1 |
| Google Photos | https://photoslibrary.googleapis.com/v1 |
| Google Analytics | https://www.googleapis.com/analytics/v3 |
If you already have bot commands using our built-in system OAuth providers (e.g., the system Gmail or Google Calendar provider) and want to switch them to use your own custom credentials, here's how:
Make sure your custom provider uses the same scope (or broader) as the system provider it replaces. If you use a narrower scope, commands may fail due to insufficient permissions.
After creating your custom provider, test it to make sure everything works correctly.
By default, your Google Cloud OAuth app is in "Testing" mode, which limits authorization to the test users you've manually added. To allow any Google user to authorize your bot:
If your bot is only used by yourself or a small team:
You only need to publish if your bot serves more than 100 users who each need to authorize with their own Google account.
Google Calendar, Google Tasks, Google Drive (file-level), Google Sheets
Google Drive (full access), Google Photos, Google Contacts
Gmail (full access), Google Fit (health data)
Cause: The redirect URI in your Google Cloud credentials doesn't match what AIBotBuilder sends.
Fix: Go to your Google Cloud credentials and make sure the Authorized Redirect URI is exactly: https://app.telegrambotbuilder.com/api/oauth/callback
Cause: The OAuth consent screen is not properly configured, or the requested scopes don't match what's configured in the consent screen.
Fix: Go to OAuth consent screen settings and ensure you've added all required scopes. Also check that the scopes in your AIBotBuilder custom provider exactly match.
Cause: The Google account trying to authorize is not a test user (while app is in testing mode).
Fix: Add the user's Gmail address to the test users list in the OAuth consent screen settings, or publish your app.
Cause: You haven't enabled the required API in your Google Cloud project.
Fix: Go to APIs & Services → Library, search for the API, and click Enable.
Cause: The scope configured in your custom provider is too narrow for what the command needs.
Fix: Check the Scopes Reference table and use a broader scope. Users will need to re-authorize after updating scopes.
Yes! A single OAuth Client ID works with any Google API. You create one Client ID per Google Cloud project and then create separate custom providers on AIBotBuilder for each Google service (each with different scopes and API base URLs), all using the same Client ID and Client Secret.
The command code doesn't change — only the OAuth credentials used for authentication. Users will need to re-authorize once when you switch to the new provider, but after that, everything works exactly the same.
Creating a project and OAuth credentials is free. Most Google Workspace APIs have generous free-tier quotas. For example, the Gmail API allows 250 quota units per user per second, and the Calendar API allows 1,000,000 queries per day. You're unlikely to hit these limits with typical bot usage.
Absolutely. Simply edit the command's OAuth settings, uncheck your custom provider, and re-check the system provider. Users will need to re-authorize once.
There's no limit on the number of custom OAuth providers you can create on AIBotBuilder. You can create separate providers for Gmail, Drive, Calendar, etc., all using the same Google Cloud project credentials.
All existing OAuth tokens will be invalidated immediately. Users will need to re-authorize, but authorization will fail since the credentials no longer exist. Make sure to switch commands back to system providers before deleting your project.
Start by creating a Google Cloud project and follow this guide step by step.