Skip to content

Connectors — Google Drive & SharePoint

Connectors let you import documents from cloud storage providers directly into your knowledge base.

Overview

Ag2Trust supports two connector types:

Provider Auth Method Features
Google Drive OAuth 2.0 Folder selection, automatic sync
SharePoint OAuth 2.0 Drive + folder selection, automatic sync

Once connected, documents are imported, processed, and made available to agents as knowledge documents.

Setting Up a Connector

Via Dashboard

  1. Go to Knowledge Base > Connectors
  2. Click Add Connector
  3. Select your provider (Google Drive or SharePoint)
  4. Complete the OAuth authorization flow
  5. Select a folder to import from
  6. Click Import

Via API (SharePoint Example)

Step 1: Initiate OAuth

The OAuth flow is initiated via the dashboard. After authorization, the connector appears in the API.

Step 2: List Connectors

curl https://api.ag2trust.com/api/v1/connectors \
  -H "X-API-Key: cust_your_api_key"

Response:

[
  {
    "id": 1,
    "provider": "sharepoint",
    "status": "connected",
    "folder_name": "Engineering Docs",
    "created_at": "2025-01-15T10:00:00Z"
  }
]

Step 3: Browse and Select a Drive (SharePoint)

# List available drives
curl https://api.ag2trust.com/api/v1/connectors/1/drives \
  -H "X-API-Key: cust_your_api_key"

# Set the active drive
curl -X PUT https://api.ag2trust.com/api/v1/connectors/1/drive \
  -H "X-API-Key: cust_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"drive_id": "abc123", "drive_name": "Engineering"}'

Step 4: Browse and Select a Folder

# Browse folders (root level)
curl "https://api.ag2trust.com/api/v1/connectors/1/drive/folders?parent_id=root" \
  -H "X-API-Key: cust_your_api_key"

# Set the target folder
curl -X PUT https://api.ag2trust.com/api/v1/connectors/1/folder \
  -H "X-API-Key: cust_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"folder_id": "folder123", "folder_name": "Product Docs"}'

Step 5: Preview and Import

# Preview files in the selected folder
curl "https://api.ag2trust.com/api/v1/connectors/1/drive/preview?folder_id=folder123" \
  -H "X-API-Key: cust_your_api_key"

# Trigger import
curl -X POST https://api.ag2trust.com/api/v1/connectors/1/import \
  -H "X-API-Key: cust_your_api_key"

Step 6: Check Import Status

curl https://api.ag2trust.com/api/v1/connectors/1/import-status \
  -H "X-API-Key: cust_your_api_key"

Managing Connectors

Disconnect a Connector

Revokes OAuth tokens and marks the connector as disconnected. Imported documents remain in your knowledge base.

curl -X POST https://api.ag2trust.com/api/v1/connectors/1/disconnect \
  -H "X-API-Key: cust_your_api_key"

Delete a Connector

Removes the connector and all imported documents.

curl -X DELETE https://api.ag2trust.com/api/v1/connectors/1 \
  -H "X-API-Key: cust_your_api_key"

API Reference

Method Endpoint Description
GET /api/v1/connectors List connectors
GET /api/v1/connectors/{id} Get connector details
DELETE /api/v1/connectors/{id} Delete connector + imported docs
POST /api/v1/connectors/{id}/disconnect Revoke OAuth, keep docs
GET /api/v1/connectors/{id}/drives List SharePoint drives
PUT /api/v1/connectors/{id}/drive Set active drive
GET /api/v1/connectors/{id}/drive/folders Browse folders
PUT /api/v1/connectors/{id}/folder Set target folder
GET /api/v1/connectors/{id}/drive/preview Preview importable files
POST /api/v1/connectors/{id}/import Trigger document import
GET /api/v1/connectors/{id}/import-status Check import progress

Best Practices

  1. Start with a specific folder — Importing an entire drive can consume your knowledge token budget quickly
  2. Monitor import status — Large folders may take several minutes to process
  3. Review imported documents — Check the Knowledge Base after import to verify documents processed correctly
  4. Use separate connectors per team — Attach connectors to specific team scopes for better organization

Troubleshooting

OAuth authorization fails

  • Ensure your organization admin has granted consent for the Ag2Trust app
  • For SharePoint, verify the Ag2Trust app has Sites.Read.All permission

Import stuck in "processing"

  • Large files (near 10MB limit) may take longer to extract text
  • Check individual document status in the Knowledge Base dashboard

Documents not appearing in agent context

  • Verify documents have status: ready (not pending or failed)
  • Confirm the documents are attached to the correct scope (org, team, or agent type)

Next Steps