The Salesforce Apex Google Drive Library offers programmatic access to Google Drive through API methods. This library simplifies coding against these APIs by providing robust methods for creating, cloning, downloading, sharing, and searching files, drives and permissions. Its implementation is accompanied by a newer version of the Google Drive API v3. You can read about the benefits here
You can find the integration configuration, including both the Google Cloud and Salesforce sides, along with all the methods, details, and challenges, in the Wiki of this repository at the following link
To get started with the Apex Google Drive library, its code needs to be deployed to your environment. All the code can either be deployed directly, contained in the google-drive
folder and fully self-contained, or the Unlocked Package can be installed for a more modular setup of the library code. If the Unlocked Package is of interest, the two buttons below, depending on the environment, can be used to install the latest version:
Note
The complete library documentation is available on the GitHub Wiki, organized into separate pages by category. Each example includes a full set of methods available for use.
To begin using this library, you first need to set up the Google Drive integration. This includes enabling the Google Drive API in the Google Admin Console, creating a Service Account, obtaining a key, and generating a certificate to upload into Salesforce. All steps are outlined in the Quick Setup Guide
Once the setup is complete, the entry point is to instantiate the GoogleDrive
class, which provides all builders, factories, and methods for interacting with the Google Drive API in an object-oriented manner. Detailed instructions for creating this instance are available on the Library Authorization Flow page
Through this instance, you gain access to three main categories: files
, drives
, and permissions
. Each category exposes a dedicated set of operations. The full hierarchy of available methods is shown below.
- .files()
- .search() –
GoogleFileSearchBuilder
- .search(String nextPageToken) –
GoogleFileSearchBuilder
- .simpleCreate() –
GoogleSimpleFileBuilder
- .multipartCreate() –
GoogleMultipartFileBuilder
- .resumableCreate() –
GoogleResumableFileBuilder
- .retrieve() –
GoogleRetrieveFileFactory
- .download() –
GoogleDownloadFileBuilder
- .export() –
GoogleExportFileBuilder
- .download() –
- .clone(String fileId) –
GoogleCloneFileBuilder
- .remove(String fileId) –
GoogleDeleteFileBuilder
- .search() –
- .drives()
- .search() –
GoogleDriveSearchBuilder
- .search(String nextPageToken) –
GoogleDriveSearchBuilder
- .search() –
- .permissions()
- .create(String fileId) –
GoogleCreatePermissionFileBuilder
- .remove(String fileId, String permissionId) –
GoogleDeletePermissionFileBuilder
- .search(String fileId) –
GooglePermissionSearchBuilder
- .create(String fileId) –