{"id":20054318,"url":"https://github.com/onedrive/onedrive-sdk-csharp","last_synced_at":"2025-05-16T08:04:27.212Z","repository":{"id":60774156,"uuid":"43524918","full_name":"OneDrive/onedrive-sdk-csharp","owner":"OneDrive","description":"OneDrive SDK for C#! https://dev.onedrive.com ","archived":true,"fork":false,"pushed_at":"2018-11-15T09:43:37.000Z","size":1043,"stargazers_count":296,"open_issues_count":1,"forks_count":142,"subscribers_count":54,"default_branch":"master","last_synced_at":"2025-05-16T08:04:21.868Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OneDrive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-01T22:38:44.000Z","updated_at":"2025-03-07T19:20:12.000Z","dependencies_parsed_at":"2022-10-04T15:26:53.700Z","dependency_job_id":null,"html_url":"https://github.com/OneDrive/onedrive-sdk-csharp","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OneDrive%2Fonedrive-sdk-csharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OneDrive%2Fonedrive-sdk-csharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OneDrive%2Fonedrive-sdk-csharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OneDrive%2Fonedrive-sdk-csharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OneDrive","download_url":"https://codeload.github.com/OneDrive/onedrive-sdk-csharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493378,"owners_count":22080126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T12:39:47.409Z","updated_at":"2025-05-16T08:04:22.203Z","avatar_url":"https://github.com/OneDrive.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OneDrive SDK for CSharp\n\n[![Build status](https://ci.appveyor.com/api/projects/status/fs9ddrmdev37v012/branch/master?svg=true)](https://ci.appveyor.com/project/OneDrive/onedrive-sdk-csharp/branch/master)\n\nIntegrate the [OneDrive API](https://dev.onedrive.com/README.htm) into your C#\nproject!\n\nThe OneDrive SDK is built as a Portable Class Library and targets the following\nframeworks: \n\n* .NET 4.5.1 \n* .NET for Windows Store apps \n* Windows Phone 8.1 and higher\n\nAzure Active Directory authentication is available for:\n\n* Windows Forms apps\n* UWP apps\n* Windows 8.1 apps\n\n## Installation via Nuget\n\nTo install the OneDrive SDK via NuGet\n\n* Search for `Microsoft.OneDriveSDK` in the NuGet Library, or\n* Type `Install-Package Microsoft.OneDriveSDK` into the Package Manager Console.\n\n## Getting started\n\n### 1. Register your application\n\nRegister your application for OneDrive by following [these](https://dev.onedrive.com/app-registration.htm) steps.\n\n### 2. Setting your application Id and scopes\n\nYour app must requests permissions in order to access a user's OneDrive. To do this, specify your app ID and scopes, or permission level.\nFor more information, see [Authentication scopes](https://dev.onedrive.com/auth/msa_oauth.htm#authentication-scopes).\n\n### 3. Getting an authenticated OneDriveClient object\n\nYou 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.\nAn example of such an imlementation can be found [MSA Auth Adapter repository](https://github.com/OneDrive/onedrive-sdk-dotnet-msa-auth-adapter). You should create the `IAuthenticationProvider`, authenticate\nusing `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,\nand the base URL for the API. Below is a sample of that pattern for authentication on the OneDrive service.\n\n```csharp\nvar msaAuthProvider = new myAuthProvider(\n    myClientId,\n    \"https://login.live.com/oauth20_desktop.srf\",\n    { \"onedrive.readonly\", \"wl.signin\" });\nawait msaAuthProvider.AuthenticateUserAsync();\nvar oneDriveClient = new OneDriveClient(\"https://api.onedrive.com/v1.0\", msaAuthProvider);\n```\n\nAfter 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](docs/auth.md).\n\n### 4. Making requests to the service\n\nOnce 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](https://dev.onedrive.com/README.htm).\n\nTo retrieve a user's drive:\n\n```csharp\n    var drive = await oneDriveClient\n                          .Drive\n                          .Request()\n                          .GetAsync();\n```\n\n`GetAsync` will return a `Drive` object on success and throw a `Microsoft.Graph.ServiceException` on error.\n\nTo get the current user's root folder of their drive:\n\n```csharp\n    var rootItem = await oneDriveClient\n                             .Drive\n                             .Root\n                             .Request()\n                             .GetAsync();\n```\n\n`GetAsync` will return an `Item` object on success and throw a `Microsoft.Graph.ServiceException` on error.\n\nFor a general overview of how the SDK is designed, see [overview](docs/overview.md).\n\nThe following sample applications are also available:\n* [OneDrive API Browser](https://github.com/OneDrive/onedrive-sample-apibrowser-dotnet) - Windows Forms app\n* [OneDrive Photo Browser](https://github.com/OneDrive/onedrive-sample-photobrowser-uwp) - Windows Universal app\n* [OneDrive Webhooks](https://github.com/OneDrive/onedrive-webhooks-aspnet) - ASP.NET MVC app\n\nTo run the OneDrivePhotoBrowser sample app your machine will need to be configured for [UWP app development](https://msdn.microsoft.com/en-us/library/windows/apps/dn609832.aspx) and the project must be associated with the Windows Store.\n\n## Documentation and resources\n\n* [Overview](docs/overview.md)\n* [Auth](docs/auth.md)\n* [Items](docs/items.md)\n* [Chunked uploads](docs/chunked-uploads.md)\n* [Collections](docs/collections.md)\n* [Errors](docs/errors.md)\n* [OneDrive API](http://dev.onedrive.com)\n\n## Issues\n\nTo view or log issues, see [issues](https://github.com/OneDrive/onedrive-sdk-csharp/issues).\n\n## Other resources\n\n* NuGet Package: [https://www.nuget.org/packages/Microsoft.OneDriveSDK](https://www.nuget.org/packages/Microsoft.OneDriveSDK)\n\n\n## License\n\n[License](LICENSE.txt)\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonedrive%2Fonedrive-sdk-csharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonedrive%2Fonedrive-sdk-csharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonedrive%2Fonedrive-sdk-csharp/lists"}