Site iconAxway Blog

AMPLIFY Integration Builder – How To Authenticate a Gmail Connector

In this blog post, we’ll look at how to use Axway’s Integration Builder to create a Gmail connector instance. We will need to create a project in the google developer console in order to get an OAuth API Key and Secret and then enter that in the Integration Builder connector instance setup screen and go through an OAuth flow.

Let’s get started.

Create a Google Application

If you have not already created a project and application, you need one to authenticate with Google. Creating an application is a multi-step process:

Create a project

Google Developer Console – Create a New Project
Google Developer Console – New Project Created

Enable APIs

Google Developer Console – Enable the Gmail API

Create a Web Application

Google Developer Console – Credentials Menu Item
Configure Consent Screen Button
Google Developer Console – OAuth Consent Screen (1 of 2)
Google Developer Console – OAuth Consent Screen (2 of 2)
Create Credentials -> OAuth Client ID
Enter a Name and the Authorized redirect URI

Note that the redirect URI (OAuth Callback URL) for Integration Builder is described here

 

ClientI D and Client Secret

Create an Integration Builder Gmail Connector Instance

Select GMail User
Grant Permission for Basic Email Settings
Grant Permission for Read/Compose/Send/Delete Email Settings
Confirm Choices
Authenticated Connector

Test Your new Gmail Connector

GET /messages

Your result should look similar to the following:

[
  {
    "threadId": "16b57e8b7dd3bc08",
    "id": "16b5806e7a4caf12"
  },
  {
    "threadId": "16b57d772a021c0a",
    "id": "16b57d772a021c0a"
  },
  {...
  {
    "threadId": "16a206bbcd29c25b",
    "id": "16a206bbcd29c25b"
  }
]
GET /messages/{id}

Your result should look similar to the following:

{
  "threadId": "16b57e8b7dd3bc08",
  "snippet": "GmailConnectorTest was granted access to your Google Account xxx@gmail.com If you did not grant access, you should check this activity and secure your account. Check activity You received this",
  "labelIds": [
    "UNREAD",
    "IMPORTANT",
    "CATEGORY_PERSONAL",
    "INBOX"
  ],
  ...
  },
  "historyId": "741783",
  "id": "16b5806e7a4caf12",
  "sizeEstimate": 11179,
  "internalDate": "1560549974000"
}

Note that this is the security email sent to my Gmail account when I authorized the Integration Builder connector access to my Gmail account using OAuth

Send an Email Using the API Docs

Go to the POST /message API and use the following for the body:

{
  "subject": "YOUR SUBJECT",
  "to": "TO EMAIL ADDRESS",
  "from": "FROM EMAIL ADRESS",
  "data": "THE MESSAGE BODY"
}

See screenshots below:

POST /message

You should receive an email at the “to” email address.

Send an Email in a Flow

In order to end an email in a flow, we’ll use the Connector API Request step. However, as we’ve seen in many other Integration Builder blog posts we first need to prepare for making the Connector API Request in a prior JS Script step.

Here is a sample JS Script step called prepareSendEmailToCustomer:

let url = '/messages';

let form = {
  body: JSON.stringify({
   "subject": "Integration Builder Gmail Connector",
  "to": "lbrenman@axway.com",
  "from": "noreply-support@axway.com",
  "data": "Integration Builder is cool! Try it out!"
  })
};

done({url:url, form:form});

The Connector API Request step is shown below:

Connector API Request Step

Summary

In this blog post, we saw how to set up Gmail for external API access via OAuth and then created a Gmail connector instance in Axway’s Integration Builder. We also saw how to send an email using the API Docs and in a flow. Now you can create Integration Builder flows that leverage Gmail.

Also, we now have a Gmail API Proxy in AMPLIFY Central that can be used in non Integration Builder applications (i.e. mobile, web, IoT, …).

Refer to other Integration Builder posts for details on how to expose the Gmail API Proxy in AMPLIFY Central such as this one that describes how to do this for a Syncplicity connector

 

 

 

Exit mobile version