This service can be used to:
Currently, OpenDAL supports OneDrive Personal only.
For write-related operations, such as:
OpenDAL's OneDrive service replaces the destination folder instead of rename it.
OneDrive does not guarantee consistency when handling a large number of concurrent requests write operations.
In some extreme cases, OneDrive may acknowledge an operation as successful but fail to commit the changes. This inconsistency can cause subsequent operations to fail, returning errors like:
You should consider [RetryLayer] and monitor your operations carefully.
access_token: Set a short-live access token for Microsoft Graph API (also, OneDrive API)refresh_token: Set a long term access token for Microsoft Graph APIclient_id: Set the client ID for a Microsoft Graph API application (available though Azure's registration portal)client_secret: Set the client secret for a Microsoft Graph API applicationroot: Set the work directory for OneDrive backendenable_versioning: Enable versioning support for OneDrive itemsThe configuration for tokens is one of the following:
access_token only, for short-lived access. Once the access_token expires, you must recreate the operator with a new token.refresh_token, client_id, and an optional client_secret, for long-lived access. The operator will automatically get and refresh the access token.signInAudience is "AzureADandPersonalMicrosoftAccount". That‘s because we’re calling Graph API with /common path segment.client_secret or not. See Public and confidential client apps for more information.client_secret.client_secret.Files.ReadWrite. And make sure the access token represents a user, because it‘s accessing the user’s onedrive by /me/drive. So “client credentials flow” won't work.refresh_token for long-lived access, add an additional offline_access scope.Read more at [OnedriveBuilder].
When you have a current access token:
use opendal_core::Operator; use opendal_core::Result; use opendal_service_onedrive::Onedrive; #[tokio::main] async fn main() -> Result<()> { // create backend builder let mut builder = Onedrive::default() .access_token("my_access_token") .root("/root/folder/for/operator"); let op: Operator = Operator::new(builder)?.finish(); Ok(()) }
When you have an Application with a refresh token:
use opendal_core::Operator; use opendal_core::Result; use opendal_service_onedrive::Onedrive; #[tokio::main] async fn main() -> Result<()> { // create backend builder let mut builder = Onedrive::default() .refresh_token("my_refresh_token") .client_id("my_client_id") .root("/root/folder/for/operator"); let op: Operator = Operator::new(builder)?.finish(); Ok(()) }