Google Drive connector

This tutorial will guide you through connecting Pathway to your data stored on Google Drive. For detailed information about Google Drive connector, refer to the API documentation.

Setting up Google Drive

To enable access to your Google Drive files through the Pathway app, you'll require a Google Cloud project and a service user.

Creating a new project in the Google API console:

A JSON file will be saved to your computer. Move it to the folder where your Pathway script is located and rename it to credentials.json.

Sharing files with service user

You can now share desired Google Drive resources with the created user. To do so, visit your Google Drive page, right click on the resource and share it with the email associated with the service user you generated earlier.

Once you've done it, you'll require the ID of the shared file or directory. You can obtain this by right-clicking on the file, selecting "Share" and then copying the link. The ID will be part of the URL.

For files: https://drive.google.com/file/d/OBJECT_ID/view?usp=drive_link
For folders: https://drive.google.com/drive/folders/OBJECT_ID?usp=drive_link

Copy the OBJECT_ID from the URL.

Connecting to Google Drive with Pathway

Once you've finished setting up your Google Drive, you can now start reading from it using pw.io.gdrive.read (ensure to replace object_id with the one you copied in the previous step):

table = pw.io.gdrive.read(
    object_id="0BzDTMZY18pgfcGg4ZXFRTDFBX0j",
    service_user_credentials_file="credentials.json"
)

pw.run()

By default, the connector operates in streaming mode, observing all changes occurring in a particular file or folder. Refresh rate can be adjusted by passing the refresh_interval parameter. Static mode can be enabled by specifying the argument mode='static'. Further information regarding available parameters can be found in API docs under this link.

connectorGoogle Drivecloud