-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3e0c640
Showing
854 changed files
with
70,724 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
*.sln.docstates | ||
*.suo | ||
*.user | ||
*.userosscache | ||
*.sln.ide | ||
TestResults/* | ||
.vs/* | ||
|
||
# UWP project files | ||
project.lock.json | ||
*StoreKey.pfx | ||
Package.StoreAssociation.xml | ||
|
||
# Build results | ||
**/[Dd]ebug/ | ||
**/[Dd]ebugPublic/ | ||
**/[Rr]elease/ | ||
**/[Rr]eleases/ | ||
**/x64/ | ||
**/x86/ | ||
**/build/ | ||
**/bld/ | ||
**/[Bb]in/ | ||
**/[Oo]bj/ | ||
|
||
# NuGet | ||
*.nupkg | ||
**/packages/* | ||
!**/packages/build/ | ||
|
||
# VS project upgrade files | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
UpgradeLog*.htm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Microsoft Graph SDK for .NET | ||
|
||
Copyright 2016 Microsoft Corporation | ||
|
||
All right reserved. | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.24720.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5E0B65FC-67B7-41F8-87BF-96D6A342C438}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{6496B661-8321-4D07-ACC2-B6602649293C}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Graph", "src\Microsoft.Graph\Microsoft.Graph.csproj", "{660FA73B-987D-4085-A230-1B04F7EAEFBC}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Graph.Test", "tests\Microsoft.Graph.Test\Microsoft.Graph.Test.csproj", "{025D498D-0FF5-4BE2-89ED-3D90D407DFFE}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|ARM = Debug|ARM | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|Any CPU = Release|Any CPU | ||
Release|ARM = Release|ARM | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Debug|ARM.ActiveCfg = Debug|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Debug|ARM.Build.0 = Debug|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Debug|x64.Build.0 = Debug|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Debug|x86.Build.0 = Debug|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Release|ARM.ActiveCfg = Release|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Release|ARM.Build.0 = Release|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Release|x64.ActiveCfg = Release|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Release|x64.Build.0 = Release|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Release|x86.ActiveCfg = Release|Any CPU | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC}.Release|x86.Build.0 = Release|Any CPU | ||
{025D498D-0FF5-4BE2-89ED-3D90D407DFFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{025D498D-0FF5-4BE2-89ED-3D90D407DFFE}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{025D498D-0FF5-4BE2-89ED-3D90D407DFFE}.Debug|ARM.ActiveCfg = Debug|Any CPU | ||
{025D498D-0FF5-4BE2-89ED-3D90D407DFFE}.Debug|ARM.Build.0 = Debug|Any CPU | ||
{025D498D-0FF5-4BE2-89ED-3D90D407DFFE}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{025D498D-0FF5-4BE2-89ED-3D90D407DFFE}.Debug|x64.Build.0 = Debug|Any CPU | ||
{025D498D-0FF5-4BE2-89ED-3D90D407DFFE}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
{025D498D-0FF5-4BE2-89ED-3D90D407DFFE}.Debug|x86.Build.0 = Debug|Any CPU | ||
{025D498D-0FF5-4BE2-89ED-3D90D407DFFE}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{025D498D-0FF5-4BE2-89ED-3D90D407DFFE}.Release|ARM.ActiveCfg = Release|Any CPU | ||
{025D498D-0FF5-4BE2-89ED-3D90D407DFFE}.Release|x64.ActiveCfg = Release|Any CPU | ||
{025D498D-0FF5-4BE2-89ED-3D90D407DFFE}.Release|x86.ActiveCfg = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{660FA73B-987D-4085-A230-1B04F7EAEFBC} = {5E0B65FC-67B7-41F8-87BF-96D6A342C438} | ||
{025D498D-0FF5-4BE2-89ED-3D90D407DFFE} = {6496B661-8321-4D07-ACC2-B6602649293C} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# Microsoft Graph SDK for C# | ||
|
||
Integrate the [Microsoft Graph API](https://graph.microsoft.io) into your C# | ||
project! | ||
|
||
The Microsoft Graph 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 | ||
|
||
## Installation via NuGet | ||
|
||
To install the Graph SDK via NuGet: | ||
|
||
* Search for `Microsoft.Graph` in the NuGet Library, or | ||
* Type `Install-Package Microsoft.Graph` into the Package Manager Console. | ||
|
||
## Getting started | ||
|
||
### 1. Register your application | ||
|
||
Register your application to use Microsoft Graph API using one of the following | ||
supported authentication providers: | ||
|
||
* [Microsoft Application Registration Portal](https://apps.dev.microsoft.com): | ||
Register a new application that works with Microsoft Account and/or | ||
organizational accounts using the Azure unified authentication end point. | ||
* [Microsoft Azure Active Directory](https://manage.windowsazure.com): Register | ||
a new application in your tenant's Active Directory to support work or school | ||
users for your tenant or multiple tenants. | ||
|
||
### 2. Setting your application id and scopes | ||
|
||
Before being granted access to Microsoft Graph APIs your application requests | ||
consent from the user for the aspects of Microsoft Graph it will be using. These | ||
are defined using authorization scopes. Your application can either ask for all | ||
required permissions initially, or can request essential scopes and then request | ||
additional scopes as necessary. | ||
|
||
For more information on available scopes, see [Authentication scopes](https://dev.onedrive.com/auth/msa_oauth.htm#authentication-scopes). | ||
|
||
### 3. Create a Microsoft Graph Client object with an authentication provider | ||
|
||
An instance of the **GraphServicesClient** class handles building requests, | ||
sending them to Microsoft Graph API, and processing the responses. To create a | ||
new instance of this class, you need to provide an instance of | ||
IAuthenticationProvider which can authenticate requests to Microsoft Graph. | ||
|
||
For consumer and converged scenarios, you can use the OAuth2AuthProvider supplied | ||
by the **Microsoft.Graph.OAuth** NuGet package. | ||
|
||
```csharp | ||
var scopes = new string[] { | ||
"https://graph.microsoft.com/files.readwrite", | ||
"https://graph.microsoft.com/users.read", | ||
"https://graph.microsoft.com/mail.read" | ||
}; | ||
var authProvider = new Microsoft.Graph.OAuth2AuthProvider("app_id", scopes) | ||
var graphClient = new Microsoft.Graph.GraphServicesClient("https://graph.microsoft.com", authProvider); | ||
``` | ||
|
||
Before using the newly created **graphCliet** object, you need to have the user | ||
login and consent to the requested scopes. You initiate the login flow by calling | ||
**LoginAsync()** on the **OAuth2AuthProvider** instance. | ||
|
||
```csharp | ||
await authProvider.LoginAsync(); | ||
``` | ||
|
||
For more information on using the OAuth2AuthProvider, see | ||
[Using the OAuth2 Authentication Provider](docs/oauth2authprovider.md). | ||
|
||
For enterprise and advanced scenarios, you can use ADAL or another authentication | ||
library and built-in **DelegateAuthProvider** class to authenticate each request. For an | ||
example, see | ||
[more information about using ADAL with Microsoft Graph SDK](docs/UsingAdalWithGraphSDK.md). | ||
|
||
### 4. Make requests to the graph | ||
|
||
Once you have completed authentication and have a GraphServicesClient, you can | ||
begin to make calls to the service. The requests in the SDK follow the format | ||
of the Microsoft Graph API's RESTful syntax. | ||
|
||
For example, to retrieve a user's OneDrive: | ||
|
||
```csharp | ||
var drive = await graphClient.Me.Drive.Request().GetAsync(); | ||
``` | ||
|
||
`GetAsync` will return a `Drive` object on success and throw a | ||
`GraphException` on error. | ||
|
||
To get the current user's root folder of their OneDrive: | ||
|
||
```csharp | ||
var rootItem = await graphClient.Me.Drive.Root.Request().GetAsync(); | ||
``` | ||
|
||
`GetAsync` will return a `DriveItem` object on success and throw a | ||
`GraphException` on error. | ||
|
||
For a general overview of how the SDK is designed, see [overview](docs/overview.md). | ||
|
||
The following sample applications are also available: | ||
* [OneDrive API Browser](samples/OneDriveApiBrowser) - Windows Forms app | ||
* [OneDrive Photo Browser](samples/OneDrivePhotoBrowser) - Windows Universal app | ||
|
||
To 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. | ||
|
||
## Documentation and resources | ||
|
||
* [Overview](docs/overview.md) | ||
* [Auth](docs/auth.md) | ||
* [Items](docs/items.md) | ||
* [Collections](docs/collections.md) | ||
* [Errors](docs/errors.md) | ||
* [OneDrive API](http://dev.onedrive.com) | ||
|
||
## Issues | ||
|
||
To view or log issues, see [issues](https://github.com/OneDrive/onedrive-sdk-csharp/issues). | ||
|
||
## Other resources | ||
|
||
* NuGet Package: [https://www.nuget.org/packages/Microsoft.OneDriveSDK](https://www.nuget.org/packages/Microsoft.OneDriveSDK) | ||
|
||
|
||
## License | ||
|
||
[License](LICENSE.txt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd"> | ||
<metadata> | ||
<id>Microsoft.Graph</id> | ||
<version>1.0.0</version> | ||
<title>Microsoft Graph .NET SDK</title> | ||
<authors>Microsoft</authors> | ||
<owners>Microsoft</owners> | ||
<requireLicenseAcceptance>true</requireLicenseAcceptance> | ||
<description>Integrate the Microsoft Graph API into your .NET app!</description> | ||
<copyright>Copyright 2016 Microsoft Corporation</copyright> | ||
<projectUrl>https://github.com/microsoftgraph/sdk-dotnet</projectUrl> | ||
<licenseUrl>http://msdn.microsoft.com/en-US/cc300389</licenseUrl> | ||
<tags>microsoft graph o365 outlook exchange sharepoint onedrive files cloud storage windowsphone windowsstore metro xaml html</tags> | ||
<dependencies> | ||
<group> | ||
<dependency id="Newtonsoft.Json" version="8.0.2" /> | ||
</group> | ||
</dependencies> | ||
|
||
</metadata> | ||
<files> | ||
<!-- PCL projects --> | ||
<file src="..\src\OneDriveSdk\bin\Release\Microsoft.Graph.dll" target="lib\portable-net45+netcore45+wpa81+win8\Microsoft.Graph.dll" /> | ||
</files> | ||
</package> |
62 changes: 62 additions & 0 deletions
62
src/Microsoft.Graph/Authentication/DelegateAuthenticationProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// ------------------------------------------------------------------------------ | ||
// Copyright (c) 2016 Microsoft Corporation | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// ------------------------------------------------------------------------------ | ||
|
||
namespace Microsoft.Graph | ||
{ | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
public delegate Task AuthenticateRequestAsyncDelegate(HttpRequestMessage request); | ||
|
||
/// <summary> | ||
/// A default <see cref="IAuthenticationProvider"/> implementation. | ||
/// </summary> | ||
public class DelegateAuthenticationProvider : IAuthenticationProvider | ||
{ | ||
/// <summary> | ||
/// Constructs an <see cref="DelegateAuthenticationProvider"/>. | ||
/// </summary> | ||
public DelegateAuthenticationProvider(AuthenticateRequestAsyncDelegate authenticateRequestAsyncDelegate) | ||
{ | ||
this.AuthenticateRequestAsyncDelegate = authenticateRequestAsyncDelegate; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the delegate for authenticating requests. | ||
/// </summary> | ||
public AuthenticateRequestAsyncDelegate AuthenticateRequestAsyncDelegate { get; set; } | ||
|
||
/// <summary> | ||
/// Authenticates the specified request message. | ||
/// </summary> | ||
/// <param name="request">The <see cref="HttpRequestMessage"/> to authenticate.</param> | ||
public Task AuthenticateRequestAsync(HttpRequestMessage request) | ||
{ | ||
if (this.AuthenticateRequestAsyncDelegate != null) | ||
{ | ||
return this.AuthenticateRequestAsyncDelegate(request); | ||
} | ||
|
||
return Task.FromResult(0); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/Microsoft.Graph/Authentication/IAuthenticationProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// ------------------------------------------------------------------------------ | ||
// Copyright (c) 2016 Microsoft Corporation | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// ------------------------------------------------------------------------------ | ||
|
||
namespace Microsoft.Graph | ||
{ | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
/// <summary> | ||
/// Interface for authenticating requests. | ||
/// </summary> | ||
public interface IAuthenticationProvider | ||
{ | ||
/// <summary> | ||
/// Authenticates the specified request message. | ||
/// </summary> | ||
/// <param name="request">The <see cref="HttpRequestMessage"/> to authenticate.</param> | ||
/// <returns>The task to await.</returns> | ||
Task AuthenticateRequestAsync(HttpRequestMessage request); | ||
} | ||
} |
Oops, something went wrong.