Connecting CBCloudDrive to Microsoft OneDrive


Requirements: CBFSCloud

This article explains how to configure CBCloudDrive to connect to Microsoft OneDrive. For a general overview of how the component works, see Getting Started with the CBCloudDrive Component.

Getting Started

First go ahead and set the ConnectionType property to ctOneDrive and set CacheDirectory to a valid, writable local directory path. OneDrive connections also require CacheEnabledForRead to be set to true. After that, you can build a connection string using the below parameters.

Connection Parameters

Parameter Description
RemoteRoot The folder within OneDrive to use as the root of the mounted drive (e.g., /Documents/Work). If left empty or set to /, the root of the OneDrive account is used.
OAuthClientId The client ID assigned when registering the application in the Azure portal.
OAuthClientSecret The client secret assigned when registering the application.
OAuthAuthorizationScope The OAuth scopes to request. A common value is offline_access files.readwrite files.readwrite.all. Refer to the Microsoft Graph permissions documentation for the full list of supported scopes.

Authentication

OneDrive authentication uses OAuth 2.0. You must first register an application in the Azure portal and configure the appropriate API permissions for Microsoft Graph. Once registered, set OAuthClientId to the application (client) ID.

On the first run, leave OAuthRefreshToken unset. The component will open a browser window for the user to authorize the application. After authorization completes, a refresh token is stored in the OAuthRefreshToken connection string parameter automatically. Save this value and include it in the connection string for all subsequent runs to avoid re-prompting the user.

drive.ConnectionType = CBCloudDriveConnectionTypes.ctOneDrive; drive.ConnectionString = "RemoteRoot=/;OAuthClientId=MY-CLIENT-ID;OAuthClientSecret=MY-SECRET;" + "OAuthAuthorizationScope=offline_access files.readwrite files.readwrite.all;";

We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@callback.com.