gdrive
gdrive
¶
Google Drive connector — bulk file sync via the Drive REST API v3.
Uses OAuth 2.0 tokens stored locally (see :mod:openjarvis.connectors.oauth).
All network calls are isolated in module-level functions (_gdrive_api_*)
to make them trivially mockable in tests.
Classes¶
GDriveConnector
¶
Bases: BaseConnector
Connector that syncs files from Google Drive via the REST API v3.
Authentication is handled through Google OAuth 2.0. Tokens are stored locally in a JSON credentials file.
| PARAMETER | DESCRIPTION |
|---|---|
credentials_path
|
Path to the JSON file where OAuth tokens are stored. Defaults to
TYPE:
|
Source code in src/openjarvis/connectors/gdrive.py
Functions¶
is_connected
¶
Return True if a credentials file with a valid access token exists.
Source code in src/openjarvis/connectors/gdrive.py
disconnect
¶
auth_url
¶
Return a Google OAuth consent URL requesting drive.readonly scope.
Source code in src/openjarvis/connectors/gdrive.py
handle_callback
¶
Handle the OAuth callback.
If code looks like a client_id:client_secret pair (containing
.apps.googleusercontent.com), store the credentials and trigger
the full browser-based OAuth flow. Otherwise treat it as a raw
token / auth code.
Source code in src/openjarvis/connectors/gdrive.py
sync
¶
sync(*, since: Optional[datetime] = None, cursor: Optional[str] = None) -> Iterator[Document]
Yield :class:Document objects for Google Drive files.
Paginates through the files.list API. Google Workspace files (Docs, Sheets, Slides) are exported as plain text or CSV. Non-exportable files are stored as metadata-only documents.
| PARAMETER | DESCRIPTION |
|---|---|
since
|
Not yet used (Drive API filtering is done server-side).
TYPE:
|
cursor
|
TYPE:
|
Source code in src/openjarvis/connectors/gdrive.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
sync_status
¶
sync_status() -> SyncStatus
Return sync progress from the most recent :meth:sync call.
Source code in src/openjarvis/connectors/gdrive.py
mcp_tools
¶
mcp_tools() -> List[ToolSpec]
Expose three MCP tool specs for real-time Google Drive queries.