Google Drive Configuration
Choose which Drive files and folders a connection reads, using either the Google Picker or explicit resource ids.
Operations on this page
| Operation | Method and path | Python | Node.js |
|---|---|---|---|
| Picker configuration | GET …/{connection_id}/gdrive/picker-config | connections.gdrive.picker_config | connections.gdrive.pickerConfig |
| List selected resources | GET …/{connection_id}/gdrive/resources | connections.gdrive.resources | connections.gdrive.resources |
| Select resources | POST …/{connection_id}/gdrive/resources | connections.gdrive.add_resources | connections.gdrive.addResources |
| Deselect a resource | DELETE …/{connection_id}/gdrive/resources/{resource_id} | connections.gdrive.remove_resource | connections.gdrive.removeResource |
Authentication and scope
| Requirement | Contract |
|---|---|
| Credential | An API key sent as X-API-Key. Connector operations are not end-user scoped. |
| Read scope | integrations:read for every GET. |
| Write scope | integrations:write for every POST, PUT, PATCH and DELETE. |
| Tenant | Derived from the authenticated key. There is no tenant parameter to pass or to get wrong. |
X-End-User-ID | Not used. A connection belongs to the organization, not to one end user. |
Before you start
You need an active Google Drive connection from the OAuth flow on Providers & OAuth. Drive cannot be connected with an API key.
1. Get the picker configuration
Returns what the browser-side Google Picker needs: the app id, the developer key, and the OAuth token scoped to this connection. Fetching it from your server and handing it to the picker means your page never holds a long-lived Google credential.
import osfrom memorysync import MemorySyncClientclient = MemorySyncClient(api_key=os.environ["MEMORYSYNC_API_KEY"],base_url="https://api.memorysync.io",)config = client.connections.gdrive.picker_config("conn_8f21a4")# Serialise this to the browser that renders the picker.print(config["app_id"], config["client_id"], config["scope"])
| Field | Passed to the Picker as |
|---|---|
app_id | The Google Cloud project number. |
client_id | The OAuth client id. |
api_key | The browser API key. This is the Picker's developerKey. |
oauth_token | The access token scoped to this connection. |
scope | The scope the token carries, so the picker can request a matching view. |
2. Select files and folders
Selecting a folder selects its contents, and MemorySync keeps following that folder — files added to it later are picked up by later syncs. Selecting a file selects only that file.
import osfrom memorysync import MemorySyncClientclient = MemorySyncClient(api_key=os.environ["MEMORYSYNC_API_KEY"],base_url="https://api.memorysync.io",)client.connections.gdrive.add_resources("conn_8f21a4",resources=[{"id": "1AbCdEfGhIjKlMnOpQrStUvWxYz", "type": "folder", "name": "Handbook"},{"id": "1ZyXwVuTsRqPoNmLkJiHgFeDcBa", "type": "file", "name": "Pricing.pdf"},],)
3. Read back the selection
Like the Slack channel list, this returns a bare JSON array rather than an object with a resources key.
import osfrom memorysync import MemorySyncClientclient = MemorySyncClient(api_key=os.environ["MEMORYSYNC_API_KEY"],base_url="https://api.memorysync.io",)for resource in client.connections.gdrive.resources("conn_8f21a4"):print(resource["resource_id"], resource["resource_type"], resource["name"], resource["permission_state"])
| Field | Meaning |
|---|---|
resource_id | Drive's own file or folder id. |
resource_type | Whether it is a file or a folder. |
name, mime_type | Drive metadata. Both nullable. |
web_view_link, icon_url | Links for showing the item back to a user. |
permission_state | Whether the connection can still read it. This is where a revoked share shows up. |
is_active, last_synced_at | Whether future syncs read it, and when it was last read. |
4. Sync and check the formats
Trigger a sync on Sync & Jobs. Google-native documents are exported before parsing; binary formats are parsed as they are. A format with no parser produces an object with no memories rather than an error, which is why an empty result is worth checking rather than assuming a failure.
| Drive content | How it is read |
|---|---|
| Google Docs | Exported to text, then extracted. |
| Google Sheets | Exported to tabular data; see structured_stats on the object. |
| Google Slides | Exported to text per slide. |
| PDF, DOCX, PPTX, XLSX | Parsed directly by the same parsers as file upload. |
| Images, audio, video | Read only where a transcriber is configured; otherwise no memories. |
| Shortcuts and shared links | Followed only if the connection's token can read the target. |
5. Deselect a resource
Stops future syncs reading it. Existing objects and memories are kept.
import osfrom memorysync import MemorySyncClientclient = MemorySyncClient(api_key=os.environ["MEMORYSYNC_API_KEY"],base_url="https://api.memorysync.io",)client.connections.gdrive.remove_resource("conn_8f21a4", "1ZyXwVuTsRqPoNmLkJiHgFeDcBa")
Errors and next action
| Status | Meaning | Next action |
|---|---|---|
401 | Missing, malformed or inactive API key. | Check server configuration without printing the key. |
403 | The key lacks integrations:read or integrations:write. | Grant the scope on the key, or use a key that has it. |
404 | The connection, object or job is not visible to this tenant. | Confirm the identifier belongs to this organization. |
409 | The connection is in a state that forbids the operation. | Read the connection status first and act on it. |
429 | Rate limited, either by MemorySync or by the upstream provider. | Back off; do not tighten a polling loop in response. |
5xx | Service failure. | Treat a write outcome as uncertain and reconcile by reading the connection back. |