Skip to main content

Setup custom GMail OAuth

You can use Your own OAuth to connect your gmail account. Please follow the steps below.

1. Setup Google Cloud Project

  • Sign in to the Google Cloud Console
  • Create a new project by name "ChakraHQ Gmail Connect" and select the same
  • Open the left nav bar from top-left icon and Select "APIs & Services"
Select APIs & Services
  • Click Enable APIs & Services
Enable APIs & Services
  • Search for and select "Gmail API", Click Enable
Gmail API
  • Go back & Click Enable APIs & Services again
  • Search for and select "Cloud Pub/Sub API", Click Enable
Cloud Pub/Sub API
  • Search for and select "Google People API", Click Enable
  • Go back to home screen of "APIs & Services"
  • Open the left nav bar from top-left icon and click "OAuth Consent Screen"
OAuth Consent Screen
  • Click "Get Started" from the overview screen
Get Started
  • Under Project configuration > App Information
    • Enter App Name as "Your BusinessName Gmail Connect"
    • Select/Add a User support email
    • Click Next
OAuth App Information
  • Under Audience
    • Select Internal
    • Click Next
Audience Selection
  • Under Contact Information
    • add a contact email address(es)
    • Click Next
Contact Information
  • Under Finish
    • Click and check the Google API Services data policy
    • Check "I agree to the Google API Services data policy"
    • Click CONTINUE
  • Review all information and click "CREATE"

3. Create OAuth Client

  • Select "Clients" from the left navigation bar
Clients
  • Click "Create Client"
Clients
  • Select "Web Application" under "Application Type"
Clients
  • Name the app "ChakraHQ"
  • Under "Authorised JavaScript origins"
  • Click "Add URI
  • Enter the url - "https://app.chakrahq.com" without quotes
  • Under "Authorized redirect URIs"
  • Click "Add URI"
  • Enter the url - "http://api.chakrahq.com/auth/google-custom/callback" without quotes
  • Click "CREATE"
  • you should see the newly created client listed under "OAuth 2.0 Client IDs"
  • Click the newly created client to show its details page

4. Configure Pub/Sub Topic

  • Search for Pub/Sub in the top search bar and select the same
Pub/Sub
  • Click "Create Topic" from the top bar
Create Topic
  • Under Topic Id enter "gmail-listener" without quotes
Topic Configuration
  • You will be redirected to the topic page
  • Here click "Create Subscription" under Subscriptions
  • Under Subscription ID, enter "gmail-webhook" without quotes
Topic Name Delivery
  • Under Retry Policy, Select "Retry after exponential backoff delay"
Retry Policy
  • Click "Create"
  • Now you need to provide permisssions to Gmail to this topic
  • Click "Topics" from the left hand nav
  • Click the "gmail-listener" topic to go its details page
  • On the right sidebar, locate the "PERMISSIONS" tab
  • Click "Add Principal"
Add Principal
  • This will open a principal creation drawer
  • Under "New Principals" enter the address - "gmail-api-push@system.gserviceaccount.com" without quotes
  • Under role, search for "publisher" and select "Pub/Sub Publisher"
Publish Permissions
  • Click "Save" to save these permissions

5. Configure Custom OAuth On ChakraHQ

  • Go to app.chakrahq.com and login if not logged in.
  • Ensure you have admin privileges
  • Go to Admin > Email Inboxes
  • Click "Connect Gmail" from the top right corner
  • Toggle the switch named "Use Custom OAuth?"
Chakra Config
  • Now enter the required information
    • "clientId"
      • You can obtain this information from the OAuth client page created in the earlier step
    • "clientSecret"
      • You can obtain this information from the OAuth client page created in the earlier step
    • "Project ID"
      • Go to Google Cloud Home
      • Select the project created in the earlier steps
      • You should see the project details as shown in the screenshot below
      • Copy the "Project ID" value
    GCP Project details
  • On Chakra Gmail OAuth Configuration page
  • Click "Save"
  • Refresh the webpage
  • Click "Connect GMail"
  • Click the "Sign in with google" button now
  • Complete the connection steps