Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
Target branch: Please verify that the pull request targets the dev branch.
Description: Provide a concise description of the changes made in this pull request.
Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
Testing: Have you written and run sufficient tests to validate the changes?
Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
BREAKING CHANGE: Significant changes that may affect compatibility
build: Changes that affect the build system or external dependencies
ci: Changes to our continuous integration processes or workflows
chore: Refactor, cleanup, or other non-functional code changes
docs: Documentation update or addition
feat: Introduces a new feature or enhancement to the codebase
fix: Bug fix or error correction
i18n: Internationalization or localization changes
perf: Performance improvement
refactor: Code restructuring for better maintainability, readability, or scalability
style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
test: Adding missing tests or correcting existing tests
WIP: Work in progress, a temporary label for incomplete or ongoing work
Changelog Entry
Description
This PR introduces Google Drive folder synchronization for Open WebUI's knowledge base system. Users can now sync entire Google Drive folders (including nested folders) with their knowledge bases, with automatic periodic synchronization. The implementation uses Google Drive service account authentication for secure server-side access without requiring OAuth flows.
Added
Google Drive folder synchronization service with automatic background scheduling
New API endpoints for Google Drive sync operations:
GET /knowledge/google-drive/service-account-email
POST /knowledge/{id}/google-drive/sync
Google Drive sync modal UI component with two-step configuration wizard
Support for synchronizing nested folders recursively
Configurable sync intervals (1-3 days in production, minutes in development)
Changed
Updated knowledge base API to support Google Drive metadata and sync operations
Add Content menu with Google Drive folder sync option
Added Google Drive specific types and interfaces
Updated package dependencies to include Google API client libraries
Deprecated
None
Removed
None
Fixed
None
Security
None
Breaking Changes
None
Notes
I'm not sure the about the contributing flow whether I should also create PR in the docs repository while this open or not. I will create the changes in that repo after getting insight on how things usually goes on this PR.
The implementation uses Google Drive service accounts which requires users to share their folders with the service account email
Sync intervals are configurable: 1-3 days in production mode, or minutes in development mode
The feature is controlled by the ENABLE_GOOGLE_DRIVE_FOLDER_SYNC environment variable
Google Workspace documents are automatically exported to compatible formats during sync
Files removed from Google Drive are automatically removed from the knowledge base during sync
Additionally Add Configurable Option for Set up DRIVE_ID and DRIVE_SECRET via Settings UI
Local Testing
Some of the local testing log:
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:251 - Google Drive API response: 3 items returned - {}
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:258 - Google Drive item: 'Conduct: Offline Center - vApr 2025' (Type: application/vnd.google-apps.document) - {}
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:258 - Google Drive item: 'Copy of Kitab Suci V.2' (Type: application/vnd.google-apps.document) - {}
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:258 - Google Drive item: 'Kitab Suci V.2' (Type: application/vnd.google-apps.document) - {}
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:286 - Google Drive: Added file 'Conduct: Offline Center - vApr 2025' to results - {}
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:286 - Google Drive: Added file 'Copy of Kitab Suci V.2' to results - {}
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:286 - Google Drive: Added file 'Kitab Suci V.2' to results - {}
2025-07-27 23:26:32.376 | INFO | open_webui.services.google_drive:list_folder_files:156 - Google Drive: Found 3 total files before filtering - {}
Screenshots or Videos
Settings UI
Knowledge Base UI
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/16072
**Author:** [@riez](https://github.com/riez)
**Created:** 7/27/2025
**Status:** 🔄 Open
**Base:** `dev` ← **Head:** `feat/google-drive-folder-sync`
---
### 📝 Commits (4)
- [`6e69da3`](https://github.com/open-webui/open-webui/commit/6e69da36f7fa4aa5a8b70cfe20900157cc60042b) feat: google drive folder sync
- [`3cc1c70`](https://github.com/open-webui/open-webui/commit/3cc1c70432dbecd2e269d6c070687e860704d9ca) fix: wrong field existing sync configurations
- [`40e8011`](https://github.com/open-webui/open-webui/commit/40e80113ca8909d90abe2c145bf3e99dbde99524) refactor: google drive service in knowledge base route into generic content sources standalone folders
- [`4346605`](https://github.com/open-webui/open-webui/commit/43466052867056913d7bc0ec963e38005c1901a2) chore: remove unused helper function
### 📊 Changes
**31 files changed** (+5645 additions, -282 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/config.py` (+13 -0)
➕ `backend/open_webui/content_sources/__init__.py` (+24 -0)
➕ `backend/open_webui/content_sources/base.py` (+245 -0)
➕ `backend/open_webui/content_sources/factory.py` (+84 -0)
➕ `backend/open_webui/content_sources/providers/__init__.py` (+1 -0)
➕ `backend/open_webui/content_sources/providers/google_drive/__init__.py` (+4 -0)
➕ `backend/open_webui/content_sources/providers/google_drive/client.py` (+587 -0)
➕ `backend/open_webui/content_sources/providers/google_drive/provider.py` (+460 -0)
➕ `backend/open_webui/content_sources/registry.py` (+125 -0)
➕ `backend/open_webui/content_sources/scheduler.py` (+261 -0)
➕ `backend/open_webui/content_sources/syncer.py` (+1385 -0)
📝 `backend/open_webui/main.py` (+31 -0)
📝 `backend/open_webui/models/files.py` (+87 -0)
➕ `backend/open_webui/routers/content_sources.py` (+279 -0)
📝 `backend/open_webui/routers/knowledge.py` (+196 -2)
📝 `backend/open_webui/routers/retrieval.py` (+37 -0)
➕ `backend/open_webui/utils/content_sources.py` (+38 -0)
📝 `src/lib/apis/knowledge/index.ts` (+128 -0)
📝 `src/lib/components/admin/Settings/Documents.svelte` (+137 -1)
📝 `src/lib/components/workspace/Knowledge/KnowledgeBase.svelte` (+45 -18)
_...and 11 more files_
</details>
### 📄 Description
# Pull Request Checklist
### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request.
**Before submitting, make sure you've checked the following:**
- [x] **Target branch:** Please verify that the pull request targets the `dev` branch.
- [x] **Description:** Provide a concise description of the changes made in this pull request.
- [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description.
- [ ] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources?
- [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation?
- [x] **Testing:** Have you written and run sufficient tests to validate the changes?
- [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
- [x] **Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following:
- **BREAKING CHANGE**: Significant changes that may affect compatibility
- **build**: Changes that affect the build system or external dependencies
- **ci**: Changes to our continuous integration processes or workflows
- **chore**: Refactor, cleanup, or other non-functional code changes
- **docs**: Documentation update or addition
- **feat**: Introduces a new feature or enhancement to the codebase
- **fix**: Bug fix or error correction
- **i18n**: Internationalization or localization changes
- **perf**: Performance improvement
- **refactor**: Code restructuring for better maintainability, readability, or scalability
- **style**: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
- **test**: Adding missing tests or correcting existing tests
- **WIP**: Work in progress, a temporary label for incomplete or ongoing work
# Changelog Entry
### Description
This PR introduces Google Drive folder synchronization for Open WebUI's knowledge base system. Users can now sync entire Google Drive folders (including nested folders) with their knowledge bases, with automatic periodic synchronization. The implementation uses Google Drive service account authentication for secure server-side access without requiring OAuth flows.
### Added
- Google Drive folder synchronization service with automatic background scheduling
- New API endpoints for Google Drive sync operations:
- GET /knowledge/google-drive/service-account-email
- POST /knowledge/{id}/google-drive/sync
- Google Drive sync modal UI component with two-step configuration wizard
- Support for synchronizing nested folders recursively
- Configurable sync intervals (1-3 days in production, minutes in development)
### Changed
- Updated knowledge base API to support Google Drive metadata and sync operations
- Add Content menu with Google Drive folder sync option
- Added Google Drive specific types and interfaces
- Updated package dependencies to include Google API client libraries
### Deprecated
- None
### Removed
- None
### Fixed
- None
### Security
- None
### Breaking Changes
- None
### Notes
I'm not sure the about the contributing flow whether I should also create PR in the docs repository while this open or not. I will create the changes in that repo after getting insight on how things usually goes on this PR.
---
### Additional Information
Opened discussion is here: https://github.com/open-webui/open-webui/discussions/14257. I think few people including myself needs this features those I created here.
- The implementation uses Google Drive service accounts which requires users to share their folders with the service account email
- Sync intervals are configurable: 1-3 days in production mode, or minutes in development mode
- The feature is controlled by the ENABLE_GOOGLE_DRIVE_FOLDER_SYNC environment variable
- Google Workspace documents are automatically exported to compatible formats during sync
- Files removed from Google Drive are automatically removed from the knowledge base during sync
- Additionally Add Configurable Option for Set up DRIVE_ID and DRIVE_SECRET via Settings UI
#### Local Testing
Some of the local testing log:
```
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:251 - Google Drive API response: 3 items returned - {}
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:258 - Google Drive item: 'Conduct: Offline Center - vApr 2025' (Type: application/vnd.google-apps.document) - {}
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:258 - Google Drive item: 'Copy of Kitab Suci V.2' (Type: application/vnd.google-apps.document) - {}
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:258 - Google Drive item: 'Kitab Suci V.2' (Type: application/vnd.google-apps.document) - {}
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:286 - Google Drive: Added file 'Conduct: Offline Center - vApr 2025' to results - {}
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:286 - Google Drive: Added file 'Copy of Kitab Suci V.2' to results - {}
2025-07-27 23:26:31.864 | INFO | open_webui.services.google_drive:_get_files_in_folder:286 - Google Drive: Added file 'Kitab Suci V.2' to results - {}
2025-07-27 23:26:32.376 | INFO | open_webui.services.google_drive:list_folder_files:156 - Google Drive: Found 3 total files before filtering - {}
```
### Screenshots or Videos
#### Settings UI
<img width="1781" height="1085" alt="image" src="https://github.com/user-attachments/assets/eeeed936-dd7d-446e-a53f-c8d432cae674" />
#### Knowledge Base UI
<img width="1787" height="456" alt="image" src="https://github.com/user-attachments/assets/f4fe296d-356e-4cf5-ad84-965b01189ebf" />
<img width="1782" height="927" alt="image" src="https://github.com/user-attachments/assets/4506813b-ed86-403a-9c4f-478e12018ba0" />
<img width="712" height="565" alt="image" src="https://github.com/user-attachments/assets/b1c55f2d-9321-4797-87f5-4796b89b682a" />
### Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/16072
Author: @riez
Created: 7/27/2025
Status: 🔄 Open
Base:
dev← Head:feat/google-drive-folder-sync📝 Commits (4)
6e69da3feat: google drive folder sync3cc1c70fix: wrong field existing sync configurations40e8011refactor: google drive service in knowledge base route into generic content sources standalone folders4346605chore: remove unused helper function📊 Changes
31 files changed (+5645 additions, -282 deletions)
View changed files
📝
backend/open_webui/config.py(+13 -0)➕
backend/open_webui/content_sources/__init__.py(+24 -0)➕
backend/open_webui/content_sources/base.py(+245 -0)➕
backend/open_webui/content_sources/factory.py(+84 -0)➕
backend/open_webui/content_sources/providers/__init__.py(+1 -0)➕
backend/open_webui/content_sources/providers/google_drive/__init__.py(+4 -0)➕
backend/open_webui/content_sources/providers/google_drive/client.py(+587 -0)➕
backend/open_webui/content_sources/providers/google_drive/provider.py(+460 -0)➕
backend/open_webui/content_sources/registry.py(+125 -0)➕
backend/open_webui/content_sources/scheduler.py(+261 -0)➕
backend/open_webui/content_sources/syncer.py(+1385 -0)📝
backend/open_webui/main.py(+31 -0)📝
backend/open_webui/models/files.py(+87 -0)➕
backend/open_webui/routers/content_sources.py(+279 -0)📝
backend/open_webui/routers/knowledge.py(+196 -2)📝
backend/open_webui/routers/retrieval.py(+37 -0)➕
backend/open_webui/utils/content_sources.py(+38 -0)📝
src/lib/apis/knowledge/index.ts(+128 -0)📝
src/lib/components/admin/Settings/Documents.svelte(+137 -1)📝
src/lib/components/workspace/Knowledge/KnowledgeBase.svelte(+45 -18)...and 11 more files
📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
This PR introduces Google Drive folder synchronization for Open WebUI's knowledge base system. Users can now sync entire Google Drive folders (including nested folders) with their knowledge bases, with automatic periodic synchronization. The implementation uses Google Drive service account authentication for secure server-side access without requiring OAuth flows.
Added
Changed
Deprecated
Removed
Fixed
Security
Breaking Changes
Notes
I'm not sure the about the contributing flow whether I should also create PR in the docs repository while this open or not. I will create the changes in that repo after getting insight on how things usually goes on this PR.
Additional Information
Opened discussion is here: https://github.com/open-webui/open-webui/discussions/14257. I think few people including myself needs this features those I created here.
Local Testing
Some of the local testing log:
Screenshots or Videos
Settings UI
Knowledge Base UI
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.