Drive API accessing shared drive folders

Hi there.
I am very new to this, but I have been able to use the actions to have my GPT access my personal drive and at the very least list the files and folders it can find (the order of which I still need to sort out).
However, I am trying to have it access a shared drive folder. Even though I am using the auth/drive scope, and the folder location is shared with me, and even anyone with the link can view, the GPT cannot find any files or folders within this location.

I have tried offering the drive ID into the main code to be the primary folder to search within, as well as configuring the instructions of the GPT to only access this ID and all child folders.

It just seems to be that no matter what I try, the GPT has no knowledge of the contents of the folder… Thoughts? I feel like I am so close to cracking it.

Hey there and welcome to the community!

There could be a few reasons for why you’re having issues, but I’d also point out I have never heard of this being a successful method. Plus, if you’re using Google drive, I feel like they would intentionally prevent GPT access and force you to use
B̶a̶r̶d̶ Gemini.

That being said, the way folks do retrieve and handle documents is through retrieval augmented generation, or RAG for short. The assistant API also has a retrieval function you can use (and is going to be far easier than attempting to hoola-hoop through shared drive issues).

The biggest thing I suspect what’s going on is that you would likely need to download the data via code. A link to a shared drive item basically says “this is the location of the data!” not “Here’s the data!” GPTs cannot autonomously download contents unless the function itself is programmed to do so.

My recommendation is to use RAG or Assistant retrieval to provide more data. Either that, or work with local files. Both are achievable and depend on your use case.

EDIT: RAG example from OpenAI cookbook

Thank you, this is the problem I am having. At times it certainly can find the files themselves, but the contents of which it has no knowledge of save a “it might be about this” based on the file name. But even finding the folders and files in the first place is tempermental.

Local files would be ideal, but we are aiming for a single source of truth for documentation, accessable to all. The idea is to have a easily sharable GPT that has a very specific knowledge base that is continually updated, rather than having to upload updated files to its knowledge whenever there is a change.

And yeah, it seems there is little info for this particular instance online, so I assume it isn’t something easily or readily achievable. Open to suggestions of course.

1 Like

For Drive API to access shared drives, you need to specify that your integration supports all kind of drives.

developers.google.com/drive/api/guides/enable-shareddrives

Correct me if I am wrong but I beleive I already have this factored in?

{
“openapi”: “3.0.0”,
“info”: {
“title”: “GPT Google Drive Document Processing”,
“version”: “1.0.0”
},
“servers”: [
{
“url”: “…/drive/v3”,
“description”: “Google Drive API server”
}
],
“paths”: {
“/files”: {
“get”: {
“summary”: “List files in a specific Google Drive folder”,
“operationId”: “listFilesInSpecificFolder”,
“parameters”: [
{
“name”: “q”,
“in”: “query”,
“required”: true,
“schema”: {
“type”: “string”,
“default”: “DRIVE ID IS HERE’ in parents”,
“description”: “Query string to list files within the specified folder. Ensure the value is URL-encoded when sent in the request.”
}
},
{
“name”: “supportsAllDrives”,
“in”: “query”,
“required”: false,
“schema”: {
“type”: “boolean”,
“default”: true,
“description”: “Parameter indicating that all drives should be included in the search.”
}
},
{
“name”: “includeItemsFromAllDrives”,
“in”: “query”,
“required”: false,
“schema”: {
“type”: “boolean”,
“default”: true,
“description”: “Parameter indicating that items from all drives should be included in the response.”
}
}
],
“responses”: {
“200”: {
“description”: “A list of files in the specified folder”,
“content”: {
“application/json”: {
“schema”: {
“type”: “object”,
“properties”: {
“files”: {
“type”: “array”,
“items”: {
“$ref”: “#/components/schemas/File”
}
}
}
}
}
}
}
}
}
}
},
“components”: {
“schemas”: {
“File”: {
“type”: “object”,
“properties”: {
“id”: {
“type”: “string”
},
“name”: {
“type”: “string”
},
“mimeType”: {
“type”: “string”
}
}
}
},
“securitySchemes”: {
“OAuth2”: {
“type”: “oauth2”,
“flows”: {
“authorizationCode”: {
“authorizationUrl”: “…auth”,
“tokenUrl”: “…/token”,
“scopes”: {
“…auth/drive.file”: “Access to file metadata and file content.”
}
}
}
}
}
},
“security”: [
{
“OAuth2”:
}
]
}

Try setting corpora parameter to: drive or allDrives and reauthenticate.
Other settings look correct.

Thanks, so let me know if I have made the correct changes, as it still cannot find any files or folders.

Also doing some tweaks to the prompts and instructions so an interesting balancing act it seems.

{
“openapi”: “3.0.0”,
“info”: {
“title”: “GPT Google Drive Document Processing”,
“version”: “1.0.0”
},
“servers”: [
{
“url”: “…/drive/v3”,
“description”: “Google Drive API server”
}
],
“paths”: {
“/files”: {
“get”: {
“summary”: “List files in a specific Google Drive folder”,
“operationId”: “listFilesInSpecificFolder”,
“parameters”: [
{
“name”: “q”,
“in”: “query”,
“required”: true,
“schema”: {
“type”: “string”,
“default”: “‘DRIVE ID GOES HERE’ in parents”,
“description”: “Query string to list files within the specified folder. Ensure the value is URL-encoded when sent in the request.”
}
},
{
“name”: “supportsAllDrives”,
“in”: “query”,
“required”: false,
“schema”: {
“type”: “boolean”,
“default”: true,
“description”: “Parameter indicating that all drives should be included in the search.”
}
},
{
“name”: “includeItemsFromAllDrives”,
“in”: “query”,
“required”: false,
“schema”: {
“type”: “boolean”,
“default”: true,
“description”: “Parameter indicating that items from all drives should be included in the response.”
}
}
],
“responses”: {
“200”: {
“description”: “A list of files in the specified folder”,
“content”: {
“application/json”: {
“schema”: {
“type”: “object”,
“properties”: {
“files”: {
“type”: “array”,
“items”: {
“$ref”: “#/components/schemas/File”
}
}
}
}
}
}
}
}
}
}
},
“components”: {
“schemas”: {
“File”: {
“type”: “object”,
“properties”: {
“id”: {
“type”: “string”
},
“name”: {
“type”: “string”
},
“mimeType”: {
“type”: “string”
}
}
}
},
“securitySchemes”: {
“OAuth2”: {
“type”: “oauth2”,
“flows”: {
“authorizationCode”: {
“authorizationUrl”: “…/auth”,
“tokenUrl”: “…/token”,
“scopes”: {
“…drive.file”: “Access to file metadata and file content.”
}
}
}
}
}
},
“security”: [
{
“OAuth2”:
}
]
}

Okay, gotcha.

So, let’s elaborate on some things, because I’m becoming increasingly wary a shared drive might be right for you here.

This sounds like RAG from your own database would be the best solution. In fact, this is typically why people create databases exclusively for RAG in the first place! :slightly_smiling_face:

This is the common perk of databases. You can update them in real time, whenever you want, to store as much as you want. Anyone you give access to can add more data to the db (just be careful - don’t give write access to everyone), and this can operate independently of the actual program you’re building.

There are plenty of vector databases you can run locally as well. It just quite frankly scales better and includes less hassle, although I do commend your effort with the shared drive.