Google Drive
Tip: GOOGLE DRIVE FOLDER IDS
Google Drive folders usually display the ID in the url while looking at them in the browser. The root folder ("My Drive") does not show its ID, however. In order to retrieve it, you will need to create a Content Service Connection and use it to retrieve the id using the following url in your browser. If the root folder id it set on the content service connection, that folder's information will be returned. If blank, the My Drive folder's information will be returned.
3sixty-admin/api/repo/{googleConnectorId}/rootfolderid
Authentication Connection
There are currently two ways to connect to Google Drive. OAuth and Java Web Token. Both require creating a project and enabling the Google Drive API for that project.

Creating your Google Project
Navigate to Google Cloud Console and sign in with your organisational Google account.
Type in the name of your project such as "3Sixty". Then click Create
Enabling APIs
Go to the following link and click select for your project from the drop-down, then click Continue.
Next, click on libraries. Then select APIs.
In the next screen, search for "Google Drive" and click "Google Drive API" from the search results.
Then, click Enable.

Use this method if you wish to authenticate as a specific user to access files and folders.
-
Navigate to the Google Cloud Console and sign in with your organisational Google account,
-
Select your project from the list.
-
Click APIs and Services in the sidebar.
You will now need to create an OAuth Consent Screen that will display when users attempt to authenticate using the app:
Setting up the OAuth Consent Screen
-
Click OAuth consent screen in the sidebar
-
Set user type to External
-
Set your app name. It can be whatever you wish unless...
-
If you intend to use the Google Vision Text Extractor name the application *3Sixty-VisionTextExtractor/1.0** as that will affect the outcome of the vision tasks (Though those will only work if your project has a linked billing account and billing enabled).
-
-
Set the support email as the one you used to log in
-
At the bottom, fill in the support email address.
-
The support email will be the email the user is directed to when they're directed to authorise 3Sixty to transfer data.
-
-
Click Save and Continue
-
Set up scopes:
Click Add Scope and check
.../auth/drive
Creating OAuth Credentials
-
Return to the APIs and Services Dashboard
-
Click Credentials
-
Click Create Credentials
-
Click OAuth Client Id
-
On the next screen, select Web Application
-
Give the credentials a name
-
Under Authorised Redirect URIs, add the following
http://{SIMFLOFY_SERVER}/3sixty-admin/authconn/oauthcb
Example. If you're running 3Sixty on a local machine
http://localhost:8080/3sixty-admin/authconn/oauthcb
Important: For Manage In Place the domain server has to be public server since Google Drive only supports public server or localhost
Tip: LOOP BACK IP
127.0.0.1 will not work, but localhost will -
Click Create
-
Your new credentials will appear under OAuth 2.0 Client IDs. Click the Download button on the right and retrieve the Client ID and Client Secret from the downloaded json file.
Creating your connector in 3Sixty
-
Go to Connections > Authentication
-
Click Create New Authentication Connection
-
Select Google OAuth Connector
-
Fill in your client id and secret, then click Authenticate
-
You will be taken to the OAuth Consent Screen you set up earlier, click Allow
-
You will be returned to 3Sixty, click Save
Completed Checklist
Ensure that you have all the following with your Google project:
-
A Google Drive API listed in your dashboard under APIs and Services
-
If using Vision Tasks: A Cloud Vision API listed in your dashboard under APIs and Services
-
A Web Application OAuth 2.0 Client, listed under Credentials of your project.
-
This should have an authorised redirect URI with the following format: {SIMFLOFY_SERVER}/3sixty-admin/authconn/oauthcb
-
-
A filled out OAuth consent form page with:
-
The ApplicationName " 3Sixty-VisionTextExtractor/1.0 " if using Vision Tasks
-
A support email to be used on the consent screen
-
The email, profile, openid, ../auth/drive
-
If using Vision Tasks ../auth/cloud-vision, ../auth/cloud-platform
-
-
-
In 3Sixty, a Google OAuth Connector using the secret key and ID from your credentials you created, and the token fields are now populated.
https://developers.google.com/identity/protocols/oauth2#expiration
Our app is in testing status, thus refresh token expires in 7 days and need to re-authenticate again!
Production status apps will not have refresh token expiry!
https://stackoverflow.com/questions/71777420/i-want-to-use-google-api-refresh-tokens-forever

Use this method if you wish to create a service user to interact with the data.
Creating The Service Account
-
Go to the APIs and Services Dashboard
-
Click Credentials
-
Click Create Credentials
-
Select Service Account
-
You will be asked you to assign roles to the account. Since we need wide-ranging access for now, we should choose Owner. This can be changed later.
-
The final screen invites other users to access this service account through their own service account portals. Use as needed for your organization.
-
Click DONE. You will be taken back to the service account list for the project.
Tip: SERVICE ACCOUNT EMAIL ADDRESS
Make note of the email address of this user. Any folders or Shared Drives you wish to migrate will need to be shared with this user. -
Click on the three dots under Actions, then click Manage Keys
-
Click ADD KEY then Create New Key, then select JSON
-
Click Create. You will download a json file to be used in the next step.

-
Go to Connections > Authentication
-
Create a Google JWT Auth Connector
-
Paste the content of that json file into the text box.
-
Click Save.
Discovery Connector
-
Authentication Connection: The Google Drive authentication connection you want to use.
-
Folder ID: The ID of the folder you wish to crawl.
-
Shared Drive ID: If this is a shared drive, put the ID here.
Integration Connection
This is used to store and write content alongside its metadata to Google Drive.
-
Connection Name: This is a unique name given to the connector instance upon creation.
-
Description: A description of the connector to help identify it better.
-
Authentication Connection: Your Google Drive Auth Connection
Job Configuration

-
Query: A query written using Google Drive's query language
-
Not compatible with Folder ID list
-
-
Crawl Queried Folders: If a queried object is a folder, crawl it.
-
Folder / File Id's: A comma delimited list of IDs to retrieve or crawl
-
Completely overrides query
-
-
This is a Shared Drive: Check if this is a shared drive in a Google Workspace
-
The id of the shared drive: Required to crawl the drive. Can be found in the URL at the root of the drive
-
Process Folders: Add folders to the document queue for processing
-
Get Versions: Will retrieve available revisions. Note that Google Drive does not keep all revisions of a document. Get versions only works for documents created in Google drive. It will not work for documents uploaded to Google Drive.
-
Get Permissions: Will retrieve permissions for each object, where available.

-
Output Folder ID: ID of the target folder, can be retrieved through the Google Drive UI
-
Include Un-Mapped Properties: If selected, all available properties will be added output file. Otherwise, only mapped properties will be included.
-
This is a Shared Drive: Check if this is a shared drive in a Google Workspace
-
The id of the shared drive: Required to crawl the drive. Can be found in the URL at the root of the drive
-
Do not update property values if file already exists: Since there is only one set of metadata per document (not per revision), this will allow you to skip mappings if the document already exists
-
Process permissions: Will take the ACL list of the document and attempt to apply these permissions in Google Drive.
-
Notify users via email when they are added to a file: If a permission is successfully added, an email will be sent to the user.
Already supported ones from before: google docs, slide, spreadsheet, drawing
Not exportable: google form, google map
Added new ones which have export link/format available:
google jamboard - pdf
google script - json
google site - txt
However, these new ones don't seem to support revisions so we can't get the revisions when getVersion is checked!
Tip: REVISIONS (VERSIONS)
If a document of the same name exists within a parent folder, the connector will attempt to create a new revision of the document, instead of uploading a new one. These revisions have the keepRevisionForever flag set to true, meaning Google Drive will not delete them automatically, as it does with most revisions. A document can have a maximum of 200 revisions.
Run and Monitor Jobs
When you run a job with Google Drive as the source repository:
These content types will be transferred as is: google docs, slide, spreadsheet, drawing
These content types will be skipped and not transferred: google form, google map
These content types will be converted to the corresponding types and will not be supported by getVersions:
-
google jamboard - pdf
-
google script - json
-
google site - txt

If the permission list is set on a document by the repository connection, Drive will attempt to set these permissions. It expects these permissions in the form `principal=permissions`. The principal must be an email address, and the allowed values for permissions are as follows:
Available for files:
-
owner
-
writer
-
commenter
-
reader
To manipulate this list, use a JavaScript task. For more information on the ACL document field and the JavaScript task. Check our Developer Documents.
Here is an example of mapping permissions from Box to Google Drive
if (rd.getACL() != null) {
var newAcl = [];
for (var i in rd.getACL()) {
var acl = rd.getACL()[i];
var split = acl.split('=');
var nRole = ''
if (split[0] != 'AutomationUser_AAAAAAAAAA@boxdevedition.com') {//This is the service user for Box, so we'll skip it
if (split[1] === 'editor') {
nRole = 'writer';
} else if (split[1] === 'owner') {
nRole = 'owner';
} else if (split[1] === 'previewer') {
nRole = 'reader';
} else if (split[1] === 'uploader') {
nRole = 'writer';
} else if (split[1] === 'previewer uploader') {
nRole = 'reader';
} else if (split[1] === 'viewer uploader') {
nRole = 'reader';
} else if (split[1] === 'co_owner') {
nRole = 'writer';
} else {
nRole = 'reader';
}
newAcl.push(split[0] + '=' + nRole);
}
}
rd.setACL(newAcl);
}
Content Services Connector
Content Service Configuration
-
Connector ID: Give your connector a unique name
-
Description: Provide a description for this connection
-
Type: Select the Filesystem Content Service Connector
-
Keep Connection Alive: Keep this connection active
-
Keep alive in Milliseconds (300000 is 5 minutes): How long until connection expires if unused
-
Connection URL: The web address for your connection
-
Security Mode: None needed for this connection
-
Mapping Type: Choose single map or group mapping if you are using mapping for jobs
-
Root Folder ID: The root folder you wish to use for uploads using the connection
Supported Methods
-
checkIn
-
checkOut
-
createFile
-
createFolder
-
createVersion
-
deleteACL
-
deleteFolder
-
deleteObjectByID
-
deleteVersion
-
getACLs
-
getFileContent
-
getObjectProperties
-
getTypes
-
getVersionContent
-
getVersionProperties
-
listFolderItems
-
listVersions
-
lockDocument
-
revertVersion
-
setACLs
-
unlockDocument
-
updateFile
-
updateProperties

Tip: These cases assume that you are working with a Google Workspace and the credentials you supply are allowed to view / access Shared Drive information.
Get a Shared Drive Id
The idbypath endpoint can be used to retrieve the id of a Shared Drive in a Google Workspace. In order to do this the folderPath argument should be the name of the Shared Drive. Additionally, the argument isDrive should be included with the call with a value of true.
Shared Drive Permissions
Passing a shared drive id to the Get ACL method should produce a list of Shared Drive Members with their respective roles.
JWT Connector
If using a JWT of service account, the service account email needs to be added as a member of Shared drive and be given Manager role.
API Keys
Google Drive Connector: Read=true: Write=true: MIP=false
Repo (Read) Specs
Key |
Description |
Data Type |
---|---|---|
gdQuery | Query | String |
crawlQueriedFolders |
If the query returns folders, crawl them |
Boolean |
gdRootFolders |
Folder / File Id's (Comma Delimited) |
String |
isSharedDrive |
This is a Shared Drive |
Boolean |
sharedDrive |
The id of the shared drive. Can be found in the URL at the root of the drive |
String |
gdProcessFolders |
Process Folders |
Boolean |
getVersions |
Get Versions |
Boolean |
getPermissions |
Get Permissions |
Boolean |
Output (Write) Specs
Key |
Description |
Data Type |
---|---|---|
outputfolderId | Output Folder Id | String |
includedUnMapped |
Include Un-Mapped Properties |
Boolean |
isSharedDrive |
This is a Shared Drive |
Boolean |
sharedDrive |
The id of the shared drive. Can be found in the URL at the root of the drive |
String |
noPropsOnUpdate |
Do not update property values if file already exists. |
Boolean |
addPerms |
Process permissions |
Boolean |
notifyUsers |
Notify users via email when they are added to a file |
Boolean |
Need help integrating with Google Drive? We can help!