Appearance
Cloud Drive Integrations
Import files from Google Drive and SharePoint/OneDrive directly into GhostAI for PII scanning, RAG indexing, and use in chat conversations.
Overview
Cloud drive integrations let users browse and import files from their connected cloud storage accounts. Imported files flow through the same pipeline as manual uploads — PII detection, malware scanning, encryption at rest, and optional RAG indexing.
Supported providers:
| Provider | API | Capabilities |
|---|---|---|
| Google Drive | Google Drive API v3 | My Drive, Shared Drives, Google Docs/Sheets/Slides export |
| SharePoint / OneDrive | Microsoft Graph API v1.0 | Personal OneDrive, SharePoint sites, followed sites |
Google Drive Setup
1. Create or configure a Google Cloud project
- Go to Google Cloud Console
- Select your existing project or create a new one
- Make sure billing is enabled (required for API access)
2. Enable the Google Drive API
- Navigate to APIs & Services → Library
- Search for Google Drive API
- Click Enable
3. Configure the OAuth consent screen
- Go to APIs & Services → OAuth consent screen
- Choose your user type:
- Internal (recommended for Google Workspace orgs) — all users in your Workspace can connect without verification. No test user setup needed.
- External — for apps used by people outside your Google Workspace org, or for personal
@gmail.comaccounts.
- Fill in the required fields:
- App name: Your app name (e.g. "GhostAI")
- User support email: Your support email
- Developer contact email: Your email
- Under Scopes, click Add or Remove Scopes and add:
openidemailhttps://www.googleapis.com/auth/drive.readonly
- Save and continue
Understanding Google's scope verification requirements
Google classifies OAuth scopes into three tiers:
| Tier | Verification required? | Examples |
|---|---|---|
| Non-sensitive | No | openid, email, profile |
| Sensitive | Yes, or test users only | drive.readonly, drive.file |
| Restricted | Yes + security assessment | drive (full access), gmail.readonly |
The drive.readonly scope is classified as sensitive. There is no non-sensitive scope that provides Drive file access. This means:
- Internal apps (Google Workspace): No verification needed. All org users can connect immediately.
- External apps in testing mode: Only explicitly listed test users can connect. Everyone else sees "Access blocked: GhostAI has not completed the Google verification process".
- External apps verified: Any Google user can connect. Requires submitting for Google's review (typically days to weeks).
Adding test users (External apps only)
If your consent screen is set to External, you must add test users before they can connect:
- On the OAuth consent screen page, scroll to Test users
- Click Add users
- Enter the email addresses of every Google account that will test the integration (up to 100)
- Save
Important: The test user email must match exactly — e.g. if someone signs in with
user@gmail.com, that's the address to add. Workspace aliases or group addresses won't work.
Production: submitting for verification
When you're ready to go live with external users:
- On the OAuth consent screen, click Publish App to move from Testing to Production
- Google will require verification since
drive.readonlyis a sensitive scope - You'll need to provide a privacy policy URL, a homepage, and a demo video showing how the scope is used
- Review typically takes 1-4 weeks
Until verified, keep the app in testing mode and manage access via the test users list.
3a. Shared credentials with Google Sign-In
Google Drive integration reuses the same OAuth Client ID and Client Secret as Google Sign-In. A single Google OAuth client supports multiple redirect URIs and different scopes for different flows.
If you already have Google Sign-In configured, you do not need to create new credentials. Your existing client already has a redirect URI for sign-in:
{BASE_URL}/api/auth/google/callbackYou just need to add the Drive integration redirect URI to the same client:
{BASE_URL}/api/integrations/google_drive/callbackBoth URIs coexist on the same OAuth client. Each flow specifies which redirect URI and which scopes it needs — Google validates that the requested redirect URI matches one of the registered ones.
If you don't have Google Sign-In configured yet, the credentials you create in Step 4 below will work for both.
4. Create OAuth 2.0 credentials (or update existing)
If you already have a Google OAuth client for sign-in, skip to step 4 below and just add the redirect URI. Otherwise, create a new client:
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth client ID (or click your existing OAuth client)
- Set Application type to Web application
- Under Authorized redirect URIs, add the Drive integration callback:
| Environment | Redirect URI |
|---|---|
| Local dev | http://localhost:8000/api/integrations/google_drive/callback |
| Staging | https://staging.example.com/api/integrations/google_drive/callback |
| Production | https://app.example.com/api/integrations/google_drive/callback |
The pattern is {BASE_URL}/api/integrations/google_drive/callback where BASE_URL matches the BASE_URL environment variable in your GhostAI backend.
- Click Create
- Copy the Client ID and Client Secret
5. Configure GhostAI environment variables
Add the following to your backend .env file:
bash
# Google OAuth credentials (same ones used for Google Sign-In)
GOOGLE_CLIENT_ID=123456789-xxxxxxxxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-xxxxxxxxxxxxxxxx
# Enable cloud integrations
INTEGRATIONS_ENABLED=true
GOOGLE_DRIVE_ENABLED=true
# Tier gating (set to "free" to allow all users, or "professional" to restrict)
INTEGRATIONS_MIN_TIER=free6. Verify BASE_URL
The redirect URI is constructed as {BASE_URL}/api/integrations/google_drive/callback. Ensure BASE_URL in your .env matches your deployment:
bash
# Local development (default)
BASE_URL=http://localhost:8000
# Production
BASE_URL=https://api.yourdomain.comThe BASE_URL value must exactly match the origin in the redirect URI you registered in Google Cloud Console.
7. Restart and test
- Restart the backend server
- Log in to GhostAI
- Go to Settings → Integrations
- You should see the Google Drive provider card
- Click Connect and complete the OAuth consent flow
SharePoint / OneDrive Setup
1. Register an Azure AD application
- Go to Azure Portal → App registrations
- Click New registration
- Set:
- Name: Your app name (e.g. "GhostAI")
- Supported account types: Choose based on your audience
- Single tenant — only your Azure AD org
- Multitenant — any Microsoft 365 organization
- Multitenant + personal — includes personal Microsoft accounts
- Under Redirect URI, select Web and add:
| Environment | Redirect URI |
|---|---|
| Local dev | http://localhost:8000/api/integrations/sharepoint/callback |
| Production | https://app.example.com/api/integrations/sharepoint/callback |
- Click Register
2. Add API permissions
- Go to API permissions → Add a permission → Microsoft Graph → Delegated permissions
- Add the following scopes:
openidoffline_accessFiles.Read.AllSites.Read.All
- If your organization requires it, click Grant admin consent (admin may need to approve)
3. Create a client secret
- Go to Certificates & secrets → Client secrets → New client secret
- Set an expiration (recommended: 24 months)
- Copy the Value (not the Secret ID) immediately — it won't be shown again
4. Configure GhostAI environment variables
bash
# Microsoft OAuth credentials (same ones used for Microsoft Sign-In)
MICROSOFT_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
MICROSOFT_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Enable cloud integrations
INTEGRATIONS_ENABLED=true
SHAREPOINT_ENABLED=true
# Tier gating
INTEGRATIONS_MIN_TIER=free5. Restart and test
Follow the same steps as Google Drive above — the SharePoint provider card will appear in Settings → Integrations.
Configuration Reference
All settings are configured via environment variables in the backend .env:
| Variable | Default | Description |
|---|---|---|
INTEGRATIONS_ENABLED | false | Master switch for all cloud integrations |
GOOGLE_DRIVE_ENABLED | false | Enable Google Drive provider |
SHAREPOINT_ENABLED | false | Enable SharePoint/OneDrive provider |
INTEGRATIONS_MIN_TIER | professional | Minimum subscription tier (free, starter, professional, enterprise) |
CLOUD_IMPORT_MAX_SIZE | 157286400 (150 MB) | Maximum file size for cloud imports (bytes) |
CLOUD_IMPORT_FOLDER_MAX_FILES | 500 | Max files when importing an entire folder |
CLOUD_IMPORT_MAX_CONCURRENT_PER_USER | 5 | Concurrent import limit per user |
CLOUD_IMPORT_MAX_CONCURRENT_PER_ORG | 20 | Concurrent import limit per organization |
CLOUD_BROWSE_CACHE_TTL | 60 | File listing cache duration (seconds) |
INTEGRATION_AUDIT_RETENTION_DAYS | 90 | How long audit log entries are retained |
BASE_URL | http://localhost:8000 | Backend URL — used to construct OAuth redirect URIs |
Multi-Account Support
Users can connect multiple accounts per provider (e.g. a personal Google Drive and a Google Workspace account). Each connection is tracked independently with its own OAuth tokens.
Integration Allowlist
Admins can restrict which users are allowed to connect cloud drive integrations using a per-provider allowlist.
How It Works
- Navigate to Admin Dashboard → Integrations → Google Drive
- In the Google Drive Allowlist section, add user IDs that should be authorized
- Only allowlisted users can initiate the OAuth connection flow
- Non-allowlisted users see a "not authorized" message directing them to contact their admin
Configuration
The allowlist is stored as the integration_user_allowlist org policy — a JSON dict mapping provider names to arrays of authorized user IDs:
json
{
"google_drive": ["user-id-1", "user-id-2"],
"sharepoint": []
}An empty array (or missing key) means all users are allowed for that provider.
Use Cases
- Phased rollout — Enable Google Drive for a pilot group before org-wide availability
- Compliance — Maintain a documented list of users with external data access
- Security — Restrict cloud storage connections to approved personnel only
Troubleshooting
"No cloud integration providers are enabled"
- Verify
INTEGRATIONS_ENABLED=truein.env - Verify at least one of
GOOGLE_DRIVE_ENABLED=trueorSHAREPOINT_ENABLED=true - Verify
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETare set (not blank or placeholder values) - Restart the backend after changing
.env
"Cloud integrations require a professional subscription"
- Set
INTEGRATIONS_MIN_TIER=freefor development/testing - In production, ensure the user's subscription tier meets the minimum
Error 403: access_denied — "has not completed the Google verification process"
This means the OAuth consent screen is set to External and in testing mode, and the Google account being used is not in the test users list.
For development/testing:
- Go to APIs & Services → OAuth consent screen → Test users
- Add the exact email address shown on the error screen
- Save and retry immediately (no propagation delay)
For production:
- Either switch to Internal (if all users are in your Google Workspace org)
- Or submit the app for Google verification (see Production: submitting for verification above)
Error 400: redirect_uri_mismatch (Google)
The redirect URI in the OAuth request doesn't match any URI registered in Google Cloud Console.
- Check your
BASE_URLenv var — it determines the redirect URI - The exact URI must be registered:
{BASE_URL}/api/integrations/google_drive/callback - Scheme (
httpvshttps), host, port, and path must all match exactly - After adding the URI in Google Cloud Console, it can take a few minutes to propagate
AADSTS50011: redirect URI mismatch (Microsoft)
Same concept as Google — the redirect URI must be registered in Azure AD: {BASE_URL}/api/integrations/sharepoint/callback
OAuth popup closes without connecting
- Check the browser console for errors
- Ensure the backend is reachable at
BASE_URL - Check backend logs for OAuth callback errors
Files fail to import
- Verify the file size is under
CLOUD_IMPORT_MAX_SIZE(default 150 MB) - Check that the user granted
drive.readonlyscope (Google) orFiles.Read.All(Microsoft) - Check backend logs for detailed error messages