Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

To use the Gmail connector, add the  <gmail.init>  element in your configuration before carrying out any other Gmail operations. The Gmail API uses OAuth2 authentication with Tokens. For more information on authentication, go to Authorizing Your App with Gmail.

Code Block
languagexml
titleinit
<gmail.init>
	<userId>{$ctx:userId}</userId>
    <refreshToken>{$ctx:refreshToken}</refreshToken>
    <clientSecret>{$ctx:clientSecret}</clientSecret>
    <clientId>{$ctx:clientId}</clientId>
    <registryPath>{$ctx:registryPath}</registryPath>
    <accessToken>{$ctx:accessToken}</accessToken>
    <apiUrl>{$ctx:apiUrl}</apiUrl>
</gmail.init>
Properties  
  • accessToken: Value of the Access Token to access the Gmail REST API.

  • refreshToken: Value of the Refresh Token, which generates a new Access Token when the previous one gets expired.    

  • apiUrl The API URL of Gmail (https://www.googleapis.com/gmail).

  • userId: User mail ID.

  • clientSecret: Value of the Client Secret you obtained when you registered your application with the Gmail API.

  • clientId: Value of the Client ID you obtained when you registered your application with Gmail API.
  • registryPath: Registry Path of the connector where the Access Token will be stored. (If not provided, the connector stores the Access Token in the connectors/Gmail/accessToken Registry Path).

Anchor
credentials
credentials
Creating the Client ID and Client Secret

Follow the steps below to obtain a Client ID and Client Secret for your Gmail account.

  1. Navigate to Google API Credentials and select your Gmail account to log in using that, to create an App to connect with the Gmail API.
  2. Click Select a Project and click NEW PROJECT, to create a project. Alternatively, you can use an existing project.
    Image Modified
  3. Enter ConnectGmailAPI as the name of the project and click Create.
    Image Modified
  4. Click Create credentials and click OAuth client ID.
    Image Modified
  5. Click Configure consent screen in the next screen.
    Image Modified
  6. Enter ConnectGmailAPI as the Product Name, and click Save.
    Image Modified
  7. Enter the following details in the Create OAuth client ID screen and click Create.

    FieldValue
    Application typeWeb application
    NameConnectGmailClient
    Authorized redirect URIs (to get the code to request an AccessToken call to theGmail API.) https://developers.google.com/oauthplayground


    You view the Client ID and Client Secret you generated. 

  8.  Copy and keep the two links saved into a text file as you will need those for the next steps, and click OK.
  9. Click Library on the side menu, search for Gmail API and click on it.
  10. Click Enable to enable the Gmail API.
  11. Anchor
    tokens
    tokens
    Obtaing the Access Token and Refresh Token

Follow the steps below to automatically refresh the expired AccessToken and Refresh Token for your Gmail account, when connecting to Google API.

  1. Navigate to the OAuth 2.0 Playground and click OAuth 2.0 Configuration button.

  2. Select Use your own OAuth credentials, enter the Client ID and Client secret you created and click Close.
  3. Under Step 1, select Gmail API v1 from the list of APIs, select all the scopes listed under except the gmail.metadata scope under it, and click Authorize APIs.
    Image RemovedImage Added
  4. Select you Gmail account and click Allow, to grant the required permissions.
  5. Under Step 2, click Exchange authorization code for tokens to generate an display the Access Token and Refresh Token. 

...