A lightweight FastAPI bridge that lets an OpenClaw agent securely read and write notes/scripts to your personal Google Drive using OAuth 2.0 (drive.file scope). Designed for self‑hosted AI assistants that need structured, file‑based memory in Drive. This project is a small FastAPI bridge that lets an OpenClaw agent read and write notes/scripts to your personal Google Drive using OAuth 2.0.
Blog Link: https://www.mutkus.com/nedir/ai/openclawi-kisisel-google-driveiniza-baglamak/
The goal:
Give your agent commands like "save this note to Drive", "write this script and store it in Drive", "open yesterday's note and summarize it".
POST /files– create or update a file under a specific Drive folderGET /files– list files under that folder (optionally filter by name)GET /files/{id}– fetch file content- Auth:
- Uses a Desktop OAuth client +
token.json(your Google account) - Scope:
https://www.googleapis.com/auth/drive.file(only files created/opened by this app)
- Uses a Desktop OAuth client +
OpenClaw-GoogleDrive-Bridge/
├── main.py # FastAPI app + Drive integration
├── requirements.txt # Python dependencies
├── README.md # (this file)
└── .gitignore # ignore venv and secrets
Important: keep
credentials.jsonandtoken.jsonout of Git.
git clone https://github.com/mutkus/OpenClaw-GoogleDrive-Bridge.git
cd OpenClaw-GoogleDrive-Bridge
python3 -m venv .venv
./.venv/bin/pip install --upgrade pip
./.venv/bin/pip install -r requirements.txtIn Google Cloud Console:
- Create/select a project.
- Enable Google Drive API.
- Configure OAuth consent screen (External, add your Gmail as test user).
- Create OAuth client ID (Application type: Desktop app).
- Download the JSON and save it next to your code as
credentials.json.
On a trusted local machine:
- Put
credentials.jsonandget_token.pyin the same folder. - Run:
python3 get_token.py- A browser window will open; log in with the Google account you want to use.
- After granting permission, a
token.jsonfile is created. - Copy both files to your server:
scp credentials.json token.json user@server:/path/to/OpenClaw-GoogleDrive-Bridge/Create a folder in Google Drive (e.g. "OpenClaw Files") and copy its ID from the URL:
OPENCLAW_GOOGLEDRIVE_FOLDER_ID = "YOUR_DRIVE_FOLDER_ID"Update this constant in main.py.
cd OpenClaw-GoogleDrive-Bridge
./.venv/bin/uvicorn main:app --host 0.0.0.0 --port 8000You can now open http://<server-ip>:8000/docs to try the API.
curl -X POST "http://localhost:8000/files" \
-H "Content-Type: application/json" \
-d '{
"name": "test-note.txt",
"content": "Hello from OpenClaw-GoogleDrive-Bridge!",
"mimeType": "text/plain",
"overwrite": true
}'curl "http://localhost:8000/files"curl "http://localhost:8000/files/<file_id>"Make sure your .gitignore includes at least:
.venv/
__pycache__/
credentials.json
token.json
service-account.json
*.pycUse any license you prefer (MIT is a good default).