Skip to content

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:

ProviderAPICapabilities
Google DriveGoogle Drive API v3My Drive, Shared Drives, Google Docs/Sheets/Slides export
SharePoint / OneDriveMicrosoft Graph API v1.0Personal OneDrive, SharePoint sites, followed sites

Google Drive Setup ​

1. Create or configure a Google Cloud project ​

  1. Go to Google Cloud Console
  2. Select your existing project or create a new one
  3. Make sure billing is enabled (required for API access)

2. Enable the Google Drive API ​

  1. Navigate to APIs & Services → Library
  2. Search for Google Drive API
  3. Click Enable
  1. Go to APIs & Services → OAuth consent screen
  2. 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.com accounts.
  3. Fill in the required fields:
    • App name: Your app name (e.g. "GhostAI")
    • User support email: Your support email
    • Developer contact email: Your email
  4. Under Scopes, click Add or Remove Scopes and add:
    • openid
    • email
    • https://www.googleapis.com/auth/drive.readonly
  5. Save and continue

Understanding Google's scope verification requirements ​

Google classifies OAuth scopes into three tiers:

TierVerification required?Examples
Non-sensitiveNoopenid, email, profile
SensitiveYes, or test users onlydrive.readonly, drive.file
RestrictedYes + security assessmentdrive (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:

  1. On the OAuth consent screen page, scroll to Test users
  2. Click Add users
  3. Enter the email addresses of every Google account that will test the integration (up to 100)
  4. 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:

  1. On the OAuth consent screen, click Publish App to move from Testing to Production
  2. Google will require verification since drive.readonly is a sensitive scope
  3. You'll need to provide a privacy policy URL, a homepage, and a demo video showing how the scope is used
  4. 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/callback

You just need to add the Drive integration redirect URI to the same client:

{BASE_URL}/api/integrations/google_drive/callback

Both 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:

  1. Go to APIs & Services → Credentials
  2. Click Create Credentials → OAuth client ID (or click your existing OAuth client)
  3. Set Application type to Web application
  4. Under Authorized redirect URIs, add the Drive integration callback:
EnvironmentRedirect URI
Local devhttp://localhost:8000/api/integrations/google_drive/callback
Staginghttps://staging.example.com/api/integrations/google_drive/callback
Productionhttps://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.

  1. Click Create
  2. 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=free

6. 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.com

The BASE_URL value must exactly match the origin in the redirect URI you registered in Google Cloud Console.

7. Restart and test ​

  1. Restart the backend server
  2. Log in to GhostAI
  3. Go to Settings → Integrations
  4. You should see the Google Drive provider card
  5. Click Connect and complete the OAuth consent flow

SharePoint / OneDrive Setup ​

1. Register an Azure AD application ​

  1. Go to Azure Portal → App registrations
  2. Click New registration
  3. 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
  4. Under Redirect URI, select Web and add:
EnvironmentRedirect URI
Local devhttp://localhost:8000/api/integrations/sharepoint/callback
Productionhttps://app.example.com/api/integrations/sharepoint/callback
  1. Click Register

2. Add API permissions ​

  1. Go to API permissions → Add a permission → Microsoft Graph → Delegated permissions
  2. Add the following scopes:
    • openid
    • offline_access
    • Files.Read.All
    • Sites.Read.All
  3. If your organization requires it, click Grant admin consent (admin may need to approve)

3. Create a client secret ​

  1. Go to Certificates & secrets → Client secrets → New client secret
  2. Set an expiration (recommended: 24 months)
  3. 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=free

5. 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:

VariableDefaultDescription
INTEGRATIONS_ENABLEDfalseMaster switch for all cloud integrations
GOOGLE_DRIVE_ENABLEDfalseEnable Google Drive provider
SHAREPOINT_ENABLEDfalseEnable SharePoint/OneDrive provider
INTEGRATIONS_MIN_TIERprofessionalMinimum subscription tier (free, starter, professional, enterprise)
CLOUD_IMPORT_MAX_SIZE157286400 (150 MB)Maximum file size for cloud imports (bytes)
CLOUD_IMPORT_FOLDER_MAX_FILES500Max files when importing an entire folder
CLOUD_IMPORT_MAX_CONCURRENT_PER_USER5Concurrent import limit per user
CLOUD_IMPORT_MAX_CONCURRENT_PER_ORG20Concurrent import limit per organization
CLOUD_BROWSE_CACHE_TTL60File listing cache duration (seconds)
INTEGRATION_AUDIT_RETENTION_DAYS90How long audit log entries are retained
BASE_URLhttp://localhost:8000Backend 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 ​

  1. Navigate to Admin Dashboard → Integrations → Google Drive
  2. In the Google Drive Allowlist section, add user IDs that should be authorized
  3. Only allowlisted users can initiate the OAuth connection flow
  4. 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=true in .env
  • Verify at least one of GOOGLE_DRIVE_ENABLED=true or SHAREPOINT_ENABLED=true
  • Verify GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET are set (not blank or placeholder values)
  • Restart the backend after changing .env

"Cloud integrations require a professional subscription" ​

  • Set INTEGRATIONS_MIN_TIER=free for 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:

  1. Go to APIs & Services → OAuth consent screen → Test users
  2. Add the exact email address shown on the error screen
  3. Save and retry immediately (no propagation delay)

For production:

Error 400: redirect_uri_mismatch (Google) ​

The redirect URI in the OAuth request doesn't match any URI registered in Google Cloud Console.

  1. Check your BASE_URL env var — it determines the redirect URI
  2. The exact URI must be registered: {BASE_URL}/api/integrations/google_drive/callback
  3. Scheme (http vs https), host, port, and path must all match exactly
  4. 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.readonly scope (Google) or Files.Read.All (Microsoft)
  • Check backend logs for detailed error messages

SOC 2 Type II Certified | BAA Available | HIPAA-Ready