-
Notifications
You must be signed in to change notification settings - Fork 122
feat: Google drive impersonator #733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maxpill
wants to merge
34
commits into
develop
Choose a base branch
from
feat/gdrive-impersonator
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
da462ae
application/pdf export to mime map
pocucan-ds 5f6b8a6
impersonation feature for client.
pocucan-ds 38ffe8b
remove impersonation at class level and define it at instance level.
pocucan-ds 466fe37
updated tests
pocucan-ds 5dd7fe4
impersonation same loop
pocucan-ds 238f8fd
updated environment variables.
pocucan-ds 4524989
impersonation support changelog
pocucan-ds f3e5255
Merge branch 'main' into extension/source/googledrive/impersonator
pocucan-ds 6a65354
updated how to and formatted.
pocucan-ds 4041158
Merge branch 'extension/source/googledrive/impersonator' of https://g…
pocucan-ds 20df7d2
updated for ruff
pocucan-ds 54da82b
updated signature
pocucan-ds da272a8
Add impersonation attributes to GoogleDriveSource and update tests fo…
maxpill 7f095c1
Merge branch 'main' into feat/gdrive-impersonator
maxpill 55c3f34
Add GoogleDriveExportFormat enum and update MIME type handling in Goo…
maxpill 43e507d
feat: force tool calling support (#751)
GlockPL 5de31a6
Merge branch 'main' into feat/gdrive-impersonator
maxpill ca72a0f
Merge branch 'feat/gdrive-impersonator' of https://github.com/deepsen…
maxpill 9290b3e
feat: force tool calling support (#751)
GlockPL c5b3f73
feat: add PydanticAI agents support (#755)
akotyla 4e60aeb
feat: Autogenerate TS types (#727)
jakubduda-dsai f267d39
fix: prompt consumes same iterator twice (#768)
ds-sebastianchwilczynski 14b1e77
feat(ui): page title & favicon customization (#767)
dazy-ds d74a13b
feat(google_drive): enhance impersonation capabilities with class-lev…
maxpill d2d5537
Merge branch 'main' into feat/gdrive-impersonator
maxpill ac54d78
fix(google_drive): remove redundant comment in credentials file path
maxpill 84e4f7f
Merge branch 'feat/gdrive-impersonator' of https://github.com/deepsen…
maxpill 6309afc
feat(google_drive): add class method for default impersonation target
maxpill a7352a9
Merge branch 'develop' of https://github.com/deepsense-ai/ragbits int…
maxpill 04ad536
feat: Optional parallel batches execution in ragbits.evaluate.Evaluat…
vladimir-kivi-ds 6cfb38c
feat(auth): Backend authentication into the chat (#761)
GlockPL 67fbd71
feat(lazy-loading): Decreasing the time needed to start the app (#753)
GlockPL f7c920a
feat(ui): initial auth plugin (#763)
dazy-ds 6316196
Merge branch 'develop' into feat/gdrive-impersonator
GlockPL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,6 +187,43 @@ async def process_drive_documents(): | |
asyncio.run(process_drive_documents()) | ||
``` | ||
|
||
## Impersonating Google Accounts | ||
|
||
You can configure your Google service account to impersonate other users in your Google Workspace domain. This is useful when you need to access files or perform actions on behalf of specific users. | ||
|
||
### Step 1: Enable Domain-Wide Delegation | ||
|
||
1. **Sign in to the [Google Admin Console](https://admin.google.com/) as a Super Admin.** | ||
2. Navigate to: | ||
**Security > Access and data control > API controls > MANAGE DOMAIN WIDE DELEGATION** | ||
3. Add a new API client or edit an existing one, and include the following OAuth scopes: | ||
- `https://www.googleapis.com/auth/cloud-platform` | ||
- `https://www.googleapis.com/auth/drive` | ||
4. Click **Authorize** or **Save** to apply the changes. | ||
|
||
### Step 2: Impersonate a User in Your Code | ||
|
||
After configuring domain-wide delegation, you can specify a target user to impersonate when using the `GoogleDriveSource` in your code. | ||
|
||
```python | ||
from ragbits.core.sources.google_drive import GoogleDriveSource | ||
|
||
target_email = "[email protected]" | ||
credentials_file = "service-account-key.json" | ||
|
||
# Set the path to your service account key file | ||
GoogleDriveSource.set_credentials_file_path(credentials_file) | ||
|
||
# Set the email address of the user to impersonate | ||
GoogleDriveSource.set_impersonation_target(target_email) | ||
``` | ||
|
||
**Note:** | ||
- The `target_email` must be a valid user in your Google Workspace domain. | ||
- Ensure your service account has been granted domain-wide delegation as described above. | ||
|
||
This setup allows your service account to act on behalf of the specified user, enabling access to their Google Drive files and resources as permitted by the assigned scopes. | ||
|
||
## Troubleshooting | ||
|
||
### Common Issues | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd put link to the part about creating this credential_file here.
This how-to is very long and I believe someone may forgot what this credential file is all about long ago. Or if they come directly to this place, they're cooked