Skip to content

OneDriveService

Upload, list, and download files from a user's OneDrive via the Microsoft Graph API.

Credentials

Uses the Entra ID app registration (tenant_id, client_id, client_secret). Typical Graph permissions: Files.ReadWrite.All.

Usage

python
from elsai_cloud.onedrive import OneDriveService

one_drive_service = OneDriveService(
    tenant_id="your_tenant_id",
    client_id="your_client_id",
    client_secret="your_client_secret",
)

Constructor parameters:

ParameterRequiredDescription
tenant_idYesAzure AD tenant ID
client_idYesAzure AD app client ID
client_secretYesAzure AD app client secret

Get user ID from email:

python
user_id = one_drive_service.get_user_id(email="your_mail_address")

Upload a file:

python
one_drive_service.upload_file_to_onedrive(
    email="your_mail_address",
    local_file_path="path/to/your/file.txt",
    folder_path="path/to/folder/in/onedrive",
)

List files in a folder:

python
files = one_drive_service.retrieve_onedrive_files_from_folder(
    email="your_mail_address",
    folder_path="path/to/folder/in/onedrive",
)

Download a file:

python
one_drive_service.download_file_from_onedrive(
    email="your_mail_address",
    file_id="your_file_id",
    target_folder="path/to/download/folder",
)

See also

Copyright © 2026 elsai foundry.