Skip to content
OneDrive SDK for C#!
Branch: master
Clone or download
Latest commit 3594584 May 8, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
Common Merge to master May 7, 2017
build Add public signing key Nov 4, 2015
docs link change again Oct 4, 2016
src/OneDriveSdk Merge branch 'master' into Invitation May 8, 2017
tests/Test.OneDriveSdk bump Graph Core version to 1.3.1 May 8, 2017
.gitignore build changes Nov 17, 2016
LICENSE.txt Initial commit Oct 2, 2015
OneDriveSdk.sln Remove sample projects from this repo Jun 30, 2016 docs to describe uploads Oct 4, 2016

OneDrive SDK for CSharp

Build status

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

Installation via Nuget

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.

Getting started

1. Register your application

Register your application for OneDrive by following these steps.

2. Setting your application Id and scopes

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.

3. Getting an authenticated OneDriveClient object

You must get a OneDriveClient object in order for your app to make requests to the service, but first you must have an instance of an object that implements IAuthenticationProvider in Microsoft.Graph.Core. An example of such an imlementation can be found MSA Auth Adapter repository. You should create the IAuthenticationProvider, authenticate using AuthenticateUserAsync(), and then create a OneDriveClient using the auth provider as a constructor argument. You must also provide the ClientId of your app, the return URL you have specified for your app, and the base URL for the API. Below is a sample of that pattern for authentication on the OneDrive service.

var msaAuthProvider = new myAuthProvider(
    { "onedrive.readonly", "wl.signin" });
await msaAuthProvider.AuthenticateUserAsync();
var oneDriveClient = new OneDriveClient("", msaAuthProvider);

After that, you will be able to use the oneDriveClient object to make calls to the service. For more information, see Authenticate your C# app for OneDrive.

4. Making requests to the service

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

GetAsync will return a Drive object on success and throw a Microsoft.Graph.ServiceException on error.

To get the current user's root folder of their drive:

    var rootItem = await oneDriveClient

GetAsync will return an Item object on success and throw a Microsoft.Graph.ServiceException on error.

For a general overview of how the SDK is designed, see overview.

The following sample applications are also available:

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.

Documentation and resources


To view or log issues, see issues.

Other resources



This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.

You can’t perform that action at this time.