Connecting to Gmail
  • 08 May 2022
  • 7 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Connecting to Gmail

  • Dark
    Light
  • PDF

The Sisense Gmail connector is a certified connector that allows you to import data from the Gmail API into Sisense via theSisense generic JDBC connector. The Gmail connector offers the most natural way to integrating Gmail capabilities such as sending and receiving email, managing Gmail folders messages, and more, in Java applications.

The support for the connector is provided by Sisense and will be assisted by the certification partner's support, if needed. For any support issues or additional functionality requests, contact your Sisense representative or open a request through the Sisense Help Center. For advanced inquiries specific to driver functionality, you can also contact the certification partner’s support directly via support@cdata.com.

After you have downloaded the driver, you can connect through a connection string in Sisense . The connection string is used to authenticate users who connect to the Gmail APIs. Once you have connected to Gmail, you can import a variety of tables from the Gmail API.

This page describes how to download the Gmail driver and deploy it, how to connect to Gmail with a connection string, provides information about the Gmail data model, and more.

Note:

For the list of supported connectors, see Introduction to Data Sources.

Downloading the Gmail JDBC Driver

You can download the Gmail JDBC driver here.

For a short video of downloading the driver, see below (the video uses the Box driver as an example).

Notes:
  • The driver is certified for Sisense v7.2 and above.
  • Sisense v7.4 and above: Click the above link to download a ready-to-use driver.
  • Sisense prior to v7.4: Click the above link to download a 30-days free-trial of the driver. Contact Sisense for the full license version.

Deploying the Bing Search JDBC Driver

Prerequisite: The install file (setup.jar) is a Java Application that requires Java 6 (J2SE) or above to run.
To install the driver, double-click the setup.jar file and proceed with the instructions in the installation wizard.
Depending on the machine on which you are accessing the Sisense application, install the driver in one of the following locations:

  • When Sisense is installed on your local machine, deploy the driver locally.

  • For a non-local installation (when accessing Sisense on a remote Windows server, or accessing the Sisense hosted cloud environment), select one of the below methods:

    • Deploy the driver on the Sisense server machine, and then perform all the authentication on the server machine.
      OR
    • Deploy the driver on your local machine (or any other machine, as convenient), perform all the authentication on that machine, and then copy the JAR file to the remote server. For detailed instructions, see here.
  • If you are on a Linux deployment, deploy the driver on your local machine (or any other machine), perform all the authentication on that machine, and then copy the JAR file to this location: /opt/sisense/storage/connectors/jdbcdrivers/driver_name_folder
    For detailed instructions, see here.

Note:

The default location of the JAR file: C:\Program Files\CData\CData JDBC Driver for <Driver Name> 2019\lib

For a short video of the process, see below (the video uses the Box driver as an example).

JAVA Troubleshooting

If you do not have Java 6 installed, you may download it from here.

If your system is not set up to run Java applications, execute the following command:
java -jar setup.jar

Connecting to Gmail

The driver communicates with Gmail through the IMAP protocol. IMAP enables all your client devices to work with the same remote data, instead of individual copies. To connect to Gmail, you will first need to enable client access to Gmail over IMAP.

Then, to access Gmail from Sisense, you create the connection string and provide Sisense with it to connect to your data.

Enabling IMAP

Follow the steps below to enable access to Gmail over IMAP:

  1. Open the Gmail Web interface and click , then select the Settings option.
  2. On the Forwarding and POP/IMAP tab, select Enable IMAP.
  3. Save your changes.

To create the connection string:

  1. Open the lib directory for the connector. This is the default path:
    C:\Program Files\CData\CData JDBC Driver for <Driver Name> 2019\lib

  2. Double-click the jar file in the lib directory.

    8-5lib-folderthumb030016.png

    Alternatively, to open the jar file from the command line, enter the following command in the command prompt (change the driver name to your driver): cd C:\Program Files\CData\CData JDBC Driver for <Driver Name> 2019\lib . Press Enter and then enter the following command (change the driver name to your driver):
    “C:\Program Files\Sisense\infra\jre\bin\java.exe" -jar cdata.jdbc.<Driver Name>.jar
    Press Enter again.
    For example:
    8-5jar-command-linethumb030016.png
    The Connection String Builder opens.

  3. Click in the Value column of the User property and set this to the user of the Gmail account.

  4. Click in the Value column of the Initiate OAuth property and select GETANDREFRESH

    8-5initiateoauthgetandrefreshthumb03007.png

  5. Click Test Connection.

  6. A browser window opens where you need to log in to your application in order to grant access. (Each application will display a different window and messages.)
    Close the Authorization Successful! message that opens.

  7. Go back to the Connection String Builder dialog and click OK in the Test Connection Successful message to close it.

  8. Click Copy to Clipboard to obtain the connection string.

For a short video of the process, see below (the video uses the XML driver as an example):

The driver uses embedded credentials that originate from a OAuth App embedded into the driver. The embedded credentials provide full functionality, so you do not have to create an OAuth App.

Note:

If you want to configure the authentication or limit the scope of the data provided to Sisense, you will need to create your own OAuth App.

You need to follow the above instructions only once, to retrieve the Access and Refresh tokens. Once the tokens have been retrieved, the driver refreshes them in the background when they expire, with no further involvement from you.

To help you create a connection string and test the connection, see Connection String Builder for Certified Connectors.

If you have any issues connecting to your data source, see https://support.sisense.com/kb/en/article/360013657533-Troubleshooting-JDBC-Data-Connectors?flash_digest=bb409caea6311b2ed547437d608be67bdab8187d.

Adding Gmail Tables to your ElastiCube

  1. Open Sisense.

    For a non-local installation, open Sisense on the hosted cloud environment.

  2. In the Data page, open an ElastiCube or create a new ElastiCube.

  3. In the Model Editor, click data_btn.png; the Add Data dialog box is displayed.

    8-5JDBC1thumb030016.png

  4. Click Generic JDBC to open the JDBC settings.

JDBC_settings.png

  1. In Connection String, paste the string you obtained above. When you do so, the string is appended with some _persist properties. The following is an example of the connection string as it looks in Sisense:
    jdbc:box:Initiate OAuth="GETANDREFRESH";_persist_oauthexpiresin=3199;_persist_token_
  2. In JDBC JARs Folder, enter the name of the directory where the Gmail JAR file is located (see Deploying the Bing Search JDBC Driver).
  3. In Driver's Class Name, enter the following class name: cdata.jdbc.gmail.GmailDriver
  4. Leave the User Name and Password blank.
  5. Click Next. A list of tables in the database are displayed. All tables and views associated with the database will appear in a new window.
  6. From the Tables list, select the relevant table or view you want to work with. You can click Next to the relevant table or click Preview to see a preview of the data inside it.
  7. (Optional) Click + to customize the data you want to import with SQL. See Importing Data with Custom Queries for more information.
  8. After you have selected all the relevant tables, click Done. The tables are added to your data model.

For a short video of the process, see below (the video uses the XML driver as an example):

Gmail Connector: Additional Resources

For the full documentation set for the Gmail connector, click here.

For connection string options, click here.

For information on the Gmail data model, click here.

Limitations

  • The default Gmail table names contain a backslash; some also contain spaces. You can use square brackets to escape the table names for the default Gmail folders.

    For example: SELECT * FROM [Gmail/All Mail]

  • Aggregate functions not supported.

  • Default message limit is 100 and does not include message content. To increase message limit, set the connection property Max Items to -1 (this will return all mail within a mailbox), or use Limit in custom query (e,g., SELECT * FROM Inbox LIMIT 9999). To include the messages, set the connection property Include Message to True.

Troubleshooting

After clicking Test Connection in the Connection String Builder, you may receive a message saying that test connection failed due to an IMAP protocol error.
If so, open the Inbox in your Gmail account to find the Critical Security Alert email. Open the email and follow its instructions to enable the driver access to less secure apps. Once enabled, go to the Connection String Builder and click Test Connection again. You recieve a Connection Successful message.


Was this article helpful?