Prerequisites

  • Google account

Step 1: Create a Project

  1. Visit https://console.cloud.google.com/home/dashboard and select the project dropdown at the top.
Google Cloud project dropdown
  1. Click New Project.
Google Cloud new project button
  1. Enter the project details and click Create.
Google Cloud create project form
  1. Select your newly created project.
Google Cloud select project
  1. Go to APIs & Services.
Google Cloud APIs & Services menu
  1. Click Enable APIs and Services.
Enable APIs and Services button
  1. Search for and select Gmail API.
Search Gmail API
  1. Click Enable.
Enable Gmail API
  1. Go back to APIs & Services and select OAuth consent screen.
OAuth consent screen menu
  1. Enter the required information and save.
OAuth consent screen form
  1. Go to Credentials in APIs & Services and click Create Credentials.
Create credentials button
  1. Select OAuth Client ID.
OAuth Client ID selection
  1. Choose Web Application and enter the required details.
Web application OAuth settings
  1. Add redirect URLs: https://api.klavis.ai/oauth/gmail/ Then click Create.
Add redirect URIs
  1. Your Client ID and Client Secret will be displayed.
OAuth credentials screen

Step 2: Request Scopes

Klavis Gmail MCP Server uses the following OAuth scopes: https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.send https://www.googleapis.com/auth/gmail.compose https://www.googleapis.com/auth/gmail.modify
  1. Go to OAuth consent screen.
OAuth consent screen
  1. Click Data Access.
Data access settings
  1. Click Add or Remove Scopes.
Add or remove scopes
  1. Enter the needed scopes and click Update.
You have successfully created a Gmail OAuth application! You now have your Client ID and Client Secret ready for integration with Klavis AI.

(Optional) Step 3: White Labeling

White labeling allows you to customize the OAuth experience with your own branding instead of Klavis AI’s.
If you want to use your own Gmail OAuth application with custom branding:
  1. Configure White Labeling: Go to https://www.klavis.ai/home/white-label
  2. Add Your Credentials: Enter your Gmail Client ID and Client Secret from Step 1.
  3. Set Redirect URI: Use https://api.klavis.ai/oauth/gmail/callback or your custom callback URL.
  4. Initiate OAuth: Use your client ID when starting the OAuth flow:
    const authUrl = `https://api.klavis.ai/oauth/gmail/authorize?instance_id=${instanceId}&client_id=${yourClientId}`;
    
For detailed white labeling implementation and code examples, see our OAuth & White Labeling guide.

Resources