Kloudless Blog

Kloudless Unified APIs enable you to code once and integrate many

This article is a part of our “Getting Started” series, with featured articles on getting started with API integrations to Dropbox, Google Calendar, Salesforce, MS Teams, and Microsoft Exchange.

Google’s Gmail service is the most popular email service available today. With the recent release of the Kloudless Unified Email API, we thought it would be helpful to provide a straightforward walkthrough of how to integrate your application with the powerful email provider. Getting started with the Gmail API is relatively simple, and requires only a few steps before you can allow your users to freely access their personal or work email messages. 

Setting Up Your Application in the Google Developer Portal

First, sign up for a developer account or log in athttps://developers.google.com/. If you have not yet created a project, visit the Google Developers Console, and create a new project.

There are a few key steps before you can start making an API request to the Gmail API.

Enabling the Gmail API

Click ENABLE APIS AND SERVICES and search for the Gmail API. Click ENABLE once you find it on the list of Google services.

Configure an OAuth Access Token

Click on Credentials if you haven’t been redirected and click ‘CREATE CREDENTIALS’ => ‘OAuth client ID’. 


You will probably want to verify your application with Google. Please fill out the verification form with this process. The verification form requires information on the scopes used, which are:

  • https://www.googleapis.com/auth/userinfo.email
  • https://www.googleapis.com/auth/gmail.modify

The scopes above are used to identify the user, monitor changes occurring in their account, and access data in their account. More specifically:

  • The User Info scope is used to retrieve the user’s email address in order to uniquely identify the connected account.
  • The Gmail scope enables all read/write operations except immediate, permanent deletion of threads and messages, which bypass Trash.

Making Your First Gmail API Request

Once your application has been configured in the Google developer portal, you are free to make calls to any endpoints available to you. As an example, we’ll set up a quick Python app to prompt for authentication and then send an email. 

First, install the official Google Python client and the necessary requirements:

Next, create a file named quickstart.py in your working directory and copy the following code to it:

When run, this code will open a browser window and you will be prompted to log in. If you are logged into multiple Google accounts, you will be asked to select one account to use for the authorization.

Next, we’ll craft the code to create and then send an email by using the messages.send method. Copy the following method to your code and make sure to fill in the appropriate args required:

This will return a base64url encoded string formatted for sending messages to the correct endpoint. Now, we just have to take that message and feed it into a method to send the message with a few more args. Copy the following method to your code:

That’s all there is to it. As long as you provide the specific arguments laid out in both methods, your application can now authenticate and send messages using Gmail. 

For more information on both these methods, and all of the available endpoints, please consult the official documentation.

Kloudless Is the Best Way to Integrate Gmail

Integrating with Gmail can take as much as 6 months of development time, and that’s not taking into account the ongoing maintenance and support to keep that connection sound in the future. 

The Kloudless Unified Email API was built to connect your application with Gmail, Microsoft Outlook, Office 365, and on-prem Exchange Server in minutes. With Kloudless, you can send, receive, and access emails from any service with real-time bi-directional sync. The Kloudless Unified Email API provides a single, common set of API endpoints and data models to send emails and retrieve email content including email attachments. Kloudless also offers extensive activity monitoring and webhooks to all of our connectors, as well as support for all major event bus services.

Kloudless also takes away the headache of maintenance and API updates, so your development team can focus on what’s important: Your app’s core functionality.

Using Kloudless With Gmail

You can sign up today for a free developer account with Kloudless and get started with integrating to Gmail or any of the other connectors provided in the Unified Email API. 

Once signed in, you will find the Callback URL or redirect URI under THIRD-PARTY SERVICES => Configuration. Please click the SaaS product Gmail and select “Use Your Gmail Keys.”

After filling in the Client ID and Client Secret, you will also need to set a specific Callback URL or Redirect URI from the Google Developer portal. Click Save and you’re all set.

To learn more about the Kloudless Unified Email API, please visit our product page or direct any inquiries to hello@kloudless.com.


Share this article:

Let’s get started. Start building for free today.