CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-source-microsoft-onedrive

Airbyte source connector for extracting data from Microsoft OneDrive cloud storage with OAuth authentication and file-based streaming capabilities.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

configuration.mddocs/

Configuration

Comprehensive configuration models for Microsoft OneDrive source connector supporting multiple authentication methods, drive selection, and file filtering options. Built with Pydantic for validation and automatic schema generation.

Capabilities

Main Configuration Specification

Primary configuration class that extends Airbyte's file-based specification with OneDrive-specific parameters.

class SourceMicrosoftOneDriveSpec(AbstractFileBasedSpec, BaseModel):
    credentials: Union[OAuthCredentials, ServiceCredentials]
    drive_name: Optional[str]
    search_scope: str
    folder_path: str
    
    class Config:
        title = "Microsoft OneDrive Source Spec"
    
    @classmethod
    def documentation_url(cls) -> str:
        """
        Provides the URL to the documentation for this specific source.
        
        Returns:
        str: Documentation URL for OneDrive integration setup
        """
    
    @classmethod
    def schema(cls, *args: Any, **kwargs: Any) -> Dict[str, Any]:
        """
        Generates the schema mapping for configuration fields.
        Cleans up legacy settings and processing options.
        
        Parameters:
        - args: Variable arguments passed to parent schema method
        - kwargs: Keyword arguments passed to parent schema method
        
        Returns:
        Dict[str, Any]: Complete JSON schema for configuration validation
        """

OAuth Authentication Credentials

OAuth 2.0 credentials model for user-delegated authentication using Microsoft Graph API.

class OAuthCredentials(BaseModel):
    auth_type: Literal["Client"]
    tenant_id: str
    client_id: str
    client_secret: str
    refresh_token: str
    
    class Config:
        title = "Authenticate via Microsoft (OAuth)"

Field Descriptions:

  • tenant_id: Tenant ID of the Microsoft OneDrive user (marked as secret)
  • client_id: Client ID of your Microsoft developer application (marked as secret)
  • client_secret: Client Secret of your Microsoft developer application (marked as secret)
  • refresh_token: Refresh Token of your Microsoft developer application (marked as secret)

Service Principal Credentials

Service key authentication model for application-only access using service principal.

class ServiceCredentials(BaseModel):
    auth_type: Literal["Service"]
    tenant_id: str
    user_principal_name: str
    client_id: str
    client_secret: str
    
    class Config:
        title = "Service Key Authentication"

Field Descriptions:

  • tenant_id: Tenant ID of the Microsoft OneDrive user (marked as secret)
  • user_principal_name: User Principal Name with special character encoding (marked as secret)
  • client_id: Client ID of your Microsoft developer application (marked as secret)
  • client_secret: Client Secret of your Microsoft developer application (marked as secret)

Configuration Fields

Drive Selection:

drive_name: Optional[str] = Field(
    title="Drive Name",
    description="Name of the Microsoft OneDrive drive where the file(s) exist.",
    default="OneDrive",
    order=2
)

Search Scope:

search_scope: str = Field(
    title="Search Scope",
    description="Specifies the location(s) to search for files. Valid options are 'ACCESSIBLE_DRIVES' to search in the selected OneDrive drive, 'SHARED_ITEMS' for shared items the user has access to, and 'ALL' to search both.",
    default="ALL",
    enum=["ACCESSIBLE_DRIVES", "SHARED_ITEMS", "ALL"],
    order=3
)

Folder Path:

folder_path: str = Field(
    title="Folder Path", 
    description="Path to a specific folder within the drives to search for files. Leave empty to search all folders of the drives. This does not apply to shared items.",
    order=4,
    default="."
)

Usage Examples

OAuth Configuration

oauth_config = {
    "credentials": {
        "auth_type": "Client",
        "tenant_id": "12345678-1234-1234-1234-123456789012",
        "client_id": "87654321-4321-4321-4321-210987654321", 
        "client_secret": "your-client-secret",
        "refresh_token": "your-refresh-token"
    },
    "drive_name": "OneDrive",
    "search_scope": "ACCESSIBLE_DRIVES",
    "folder_path": "Documents/Reports",
    "streams": [{
        "name": "reports",
        "globs": ["*.xlsx", "*.csv"],
        "validation_policy": "Emit Record",
        "format": {"filetype": "csv"}
    }]
}

Service Principal Configuration

service_config = {
    "credentials": {
        "auth_type": "Service",
        "tenant_id": "12345678-1234-1234-1234-123456789012",
        "user_principal_name": "datauser@company.onmicrosoft.com",
        "client_id": "87654321-4321-4321-4321-210987654321",
        "client_secret": "your-app-secret"
    },
    "drive_name": "OneDrive", 
    "search_scope": "ALL",
    "folder_path": ".",
    "streams": [{
        "name": "all_files",
        "globs": ["**/*"],
        "validation_policy": "Emit Record", 
        "format": {"filetype": "unstructured"}
    }]
}

Schema Generation

from source_microsoft_onedrive.spec import SourceMicrosoftOneDriveSpec

# Generate complete configuration schema
schema = SourceMicrosoftOneDriveSpec.schema()

# Access documentation URL
doc_url = SourceMicrosoftOneDriveSpec.documentation_url()
print(doc_url)  # "https://docs.airbyte.com/integrations/sources/one-drive"

Search Scope Options

  • ACCESSIBLE_DRIVES: Search only in the specified drive_name (typically "OneDrive")
  • SHARED_ITEMS: Search only in items shared with the authenticated user
  • ALL: Search both accessible drives and shared items (default)

File Path Handling

  • Root Path: Use "." or "/" to search from the drive root
  • Nested Paths: Specify folder paths like "Documents/Projects" or "Shared Documents"
  • Shared Items: folder_path setting does not apply to shared items scope

Authentication Security

All credential fields are marked with airbyte_secret=True for proper secret handling:

  • Values are masked in logs and UI
  • Encrypted storage in Airbyte configurations
  • Secure transmission during connector operations

Configuration Validation

The Pydantic models provide automatic validation:

  • Required Fields: All credential fields are required
  • Format Validation: Ensures proper auth_type discriminator values
  • Enum Validation: search_scope must be one of the allowed values
  • Default Values: Sensible defaults for optional fields

Install with Tessl CLI

npx tessl i tessl/pypi-source-microsoft-onedrive

docs

authentication.md

configuration.md

file-operations.md

index.md

source-connector.md

tile.json