Integrate the OneDrive API into your C# project!
The OneDrive SDK is built as a Portable Class Library and targets the following frameworks:
- .NET 4.5.1
- .NET for Windows Store apps
- Windows Phone 8.1 and higher
Azure Active Directory authentication is available for:
- Windows Forms apps
- UWP apps
- Windows 8.1 apps
To install the OneDrive SDK via NuGet
- Search for
Microsoft.OneDriveSDK
in the NuGet Library, or - Type
Install-Package Microsoft.OneDriveSDK
into the Package Manager Console.
Register your application for OneDrive by following these steps.
Your app must requests permissions in order to access a user's OneDrive. To do this, specify your app ID and scopes, or permission level. For more information, see Authentication scopes.
The OneDriveClient object will handle authentication for you. You must get a OneDriveClient object in order for your app to make requests to the service. For more information, see Authenticate your C# app for OneDrive.
Once you have a OneDriveClient that is authenticated you can begin to make calls against the service. The requests against the service look like OneDrive's REST API.
To retrieve a user's drive:
var drive = await oneDriveClient
.Drive
.Request()
.GetAsync();
GetAsync
will return a Drive
object on success and throw a OneDriveException
on error.
To get the current user's root folder of their drive:
var rootItem = await oneDriveClient
.Drive
.Root
.Request()
.GetAsync();
GetAsync
will return an Item
object on success and throw a OneDriveException
on error.
For a general overview of how the SDK is designed, see overview.
The following sample applications are also available:
- OneDrive API Browser - Windows Forms app
- OneDrive Photo Browser - Windows Universal app
To run the OneDrivePhotoBrowser sample app your machine will need to be configured for UWP app development and the project must be associated with the Windows Store.
To view or log issues, see issues.
- NuGet Package: https://www.nuget.org/packages/Microsoft.OneDriveSDK