├── dotnetcore-graph-mvcapp
├── content
│ ├── wwwroot
│ │ ├── js
│ │ │ ├── site.min.js
│ │ │ └── site.js
│ │ ├── favicon.ico
│ │ ├── lib
│ │ │ ├── bootstrap
│ │ │ │ ├── dist
│ │ │ │ │ ├── fonts
│ │ │ │ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ │ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ │ │ │ ├── glyphicons-halflings-regular.woff
│ │ │ │ │ │ └── glyphicons-halflings-regular.woff2
│ │ │ │ │ └── js
│ │ │ │ │ │ └── npm.js
│ │ │ │ ├── .bower.json
│ │ │ │ └── LICENSE
│ │ │ ├── jquery
│ │ │ │ ├── .bower.json
│ │ │ │ └── LICENSE.txt
│ │ │ ├── jquery-validation
│ │ │ │ ├── .bower.json
│ │ │ │ └── LICENSE.md
│ │ │ └── jquery-validation-unobtrusive
│ │ │ │ ├── .bower.json
│ │ │ │ └── jquery.validate.unobtrusive.min.js
│ │ ├── css
│ │ │ ├── site.min.css
│ │ │ └── site.css
│ │ └── images
│ │ │ └── banner2.svg
│ ├── Views
│ │ ├── _ViewStart.cshtml
│ │ ├── _ViewImports.cshtml
│ │ ├── Home
│ │ │ ├── About.cshtml
│ │ │ ├── Contact.cshtml
│ │ │ └── Index.cshtml
│ │ └── Shared
│ │ │ ├── Error.cshtml
│ │ │ ├── _ValidationScriptsPartial.cshtml
│ │ │ └── _Layout.cshtml
│ ├── obj
│ │ ├── Debug
│ │ │ └── netcoreapp2.0
│ │ │ │ ├── content.AssemblyInfoInputs.cache
│ │ │ │ ├── content.csproj.CoreCompileInputs.cache
│ │ │ │ ├── content.dll
│ │ │ │ ├── content.pdb
│ │ │ │ ├── content.assets.cache
│ │ │ │ ├── content.csprojAssemblyReference.cache
│ │ │ │ ├── content.csprojResolveAssemblyReference.cache
│ │ │ │ ├── project.razor.json
│ │ │ │ ├── content.AssemblyInfo.cs
│ │ │ │ └── content.csproj.FileListAbsolute.txt
│ │ ├── content.csproj.nuget.cache
│ │ ├── content.csproj.nuget.g.props
│ │ └── content.csproj.nuget.g.targets
│ ├── appsettings.json
│ ├── bin
│ │ └── Debug
│ │ │ └── netcoreapp2.0
│ │ │ ├── content.dll
│ │ │ ├── content.pdb
│ │ │ ├── content.runtimeconfig.json
│ │ │ └── content.runtimeconfig.dev.json
│ ├── Helpers
│ │ ├── IGrahpSDKHelper.cs
│ │ ├── GraphSettings.cs
│ │ ├── GraphSDKHelper.cs
│ │ └── SessionTokenCache.cs
│ ├── appsettings.Development.json
│ ├── Models
│ │ └── ErrorViewModel.cs
│ ├── content.csproj
│ ├── Program.cs
│ ├── bundleconfig.json
│ ├── .template.config
│ │ └── template.json
│ ├── Controllers
│ │ └── HomeController.cs
│ └── Startup.cs
├── chenxizhang.dotnetcore.msgraph.mvcapp.CSharp.1.0.0.nupkg
├── content.nuspec
├── lang
│ ├── zh-cn
│ │ └── README.md
│ └── zh-tw
│ │ └── README.md
└── README.md
├── dotnetcore-graph-webapi
├── content
│ ├── client
│ │ ├── obj
│ │ │ ├── Debug
│ │ │ │ └── netcoreapp2.2
│ │ │ │ │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
│ │ │ │ │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
│ │ │ │ │ ├── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
│ │ │ │ │ ├── client.AssemblyInfoInputs.cache
│ │ │ │ │ ├── client.csproj.CoreCompileInputs.cache
│ │ │ │ │ ├── client.assets.cache
│ │ │ │ │ ├── client.csprojAssemblyReference.cache
│ │ │ │ │ ├── project.razor.json
│ │ │ │ │ └── client.AssemblyInfo.cs
│ │ │ ├── client.csproj.nuget.cache
│ │ │ ├── client.csproj.nuget.g.targets
│ │ │ └── client.csproj.nuget.g.props
│ │ ├── client.csproj
│ │ └── Program.cs
│ ├── webapi
│ │ ├── obj
│ │ │ ├── Debug
│ │ │ │ └── netcoreapp2.2
│ │ │ │ │ ├── TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
│ │ │ │ │ ├── TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
│ │ │ │ │ ├── TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
│ │ │ │ │ ├── webapi.RazorAssemblyInfo.cache
│ │ │ │ │ ├── webapi.AssemblyInfoInputs.cache
│ │ │ │ │ ├── webapi.csproj.CoreCompileInputs.cache
│ │ │ │ │ ├── webapi.assets.cache
│ │ │ │ │ ├── webapi.csprojAssemblyReference.cache
│ │ │ │ │ ├── project.razor.json
│ │ │ │ │ ├── webapi.RazorAssemblyInfo.cs
│ │ │ │ │ └── webapi.AssemblyInfo.cs
│ │ │ ├── webapi.csproj.nuget.cache
│ │ │ ├── webapi.csproj.nuget.g.targets
│ │ │ └── webapi.csproj.nuget.g.props
│ │ ├── appsettings.json
│ │ ├── appsettings.Development.json
│ │ ├── webapi.csproj
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── Controllers
│ │ │ └── ValuesController.cs
│ │ └── Startup.cs
│ ├── .template.config
│ │ └── template.json
│ └── content.sln
├── chenxizhang.dotnetcore.msgraph.webapi.CSharp.1.0.2.nupkg
├── content.nuspec
├── lang
│ ├── zh-cn
│ │ └── README.md
│ └── zh-tw
│ │ └── README.md
└── README.md
├── dotnetcore-graph-webapp
├── content
│ ├── obj
│ │ ├── Debug
│ │ │ └── netcoreapp2.0
│ │ │ │ ├── content.AssemblyInfoInputs.cache
│ │ │ │ ├── content.csproj.CoreCompileInputs.cache
│ │ │ │ ├── content.dll
│ │ │ │ ├── content.pdb
│ │ │ │ ├── content.assets.cache
│ │ │ │ ├── project.razor.json
│ │ │ │ ├── content.AssemblyInfo.cs
│ │ │ │ └── content.csproj.FileListAbsolute.txt
│ │ ├── content.csproj.nuget.cache
│ │ ├── content.csproj.nuget.g.props
│ │ └── content.csproj.nuget.g.targets
│ ├── bin
│ │ └── Debug
│ │ │ └── netcoreapp2.0
│ │ │ ├── content.dll
│ │ │ ├── content.pdb
│ │ │ ├── content.runtimeconfig.json
│ │ │ └── content.runtimeconfig.dev.json
│ ├── content.csproj
│ ├── Program.cs
│ ├── .template.config
│ │ └── template.json
│ └── SessionTokenCache.cs
├── chenxizhang.dotnetcore.msgraph.webapp.CSharp.1.0.0.nupkg
├── content.nuspec
├── lang
│ ├── zh-cn
│ │ └── README.md
│ └── zh-tw
│ │ └── README.md
└── README.md
├── dotnetcore-graph-console
├── content
│ ├── obj
│ │ ├── Debug
│ │ │ └── netcoreapp2.0
│ │ │ │ ├── content.AssemblyInfoInputs.cache
│ │ │ │ ├── content.csproj.CoreCompileInputs.cache
│ │ │ │ ├── content.assets.cache
│ │ │ │ ├── content.csprojAssemblyReference.cache
│ │ │ │ ├── project.razor.json
│ │ │ │ └── content.AssemblyInfo.cs
│ │ ├── content.csproj.nuget.cache
│ │ ├── content.csproj.nuget.g.targets
│ │ └── content.csproj.nuget.g.props
│ ├── content.csproj
│ ├── .template.config
│ │ └── template.json
│ └── Program.cs
├── chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.0.nupkg
├── chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.1.nupkg
├── chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.2.nupkg
├── chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.3.nupkg
├── chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.4.nupkg
├── chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.5.nupkg
├── content.nuspec
├── lang
│ ├── zh-cn
│ │ └── README.md
│ └── zh-tw
│ │ └── README.md
└── README.md
├── dotnetcore-graph-serviceapp
├── content
│ ├── obj
│ │ ├── Debug
│ │ │ └── netcoreapp2.0
│ │ │ │ ├── content.AssemblyInfoInputs.cache
│ │ │ │ ├── content.csproj.CoreCompileInputs.cache
│ │ │ │ ├── content.dll
│ │ │ │ ├── content.pdb
│ │ │ │ ├── content.assets.cache
│ │ │ │ ├── project.razor.json
│ │ │ │ ├── content.AssemblyInfo.cs
│ │ │ │ └── content.csproj.FileListAbsolute.txt
│ │ ├── content.csproj.nuget.cache
│ │ ├── content.csproj.nuget.g.targets
│ │ └── content.csproj.nuget.g.props
│ ├── bin
│ │ └── Debug
│ │ │ └── netcoreapp2.0
│ │ │ ├── content.dll
│ │ │ ├── content.pdb
│ │ │ ├── content.runtimeconfig.json
│ │ │ └── content.runtimeconfig.dev.json
│ ├── content.csproj
│ ├── .template.config
│ │ └── template.json
│ └── Program.cs
├── chenxizhang.dotnetcore.msgraph.serviceapp.CSharp.1.0.0.nupkg
├── chenxizhang.dotnetcore.msgraph.serviceapp.CSharp.1.0.1.nupkg
├── content.nuspec
├── lang
│ ├── zh-cn
│ │ └── README.md
│ └── zh-tw
│ │ └── README.md
└── README.md
├── .gitignore
├── .vscode
├── tasks.json
└── launch.json
├── LICENSE
├── lang
├── zh-cn
│ └── README.md
└── zh-tw
│ └── README.md
└── README.md
/dotnetcore-graph-mvcapp/content/wwwroot/js/site.min.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/js/site.js:
--------------------------------------------------------------------------------
1 | // Write your JavaScript code.
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Views/_ViewStart.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | Layout = "_Layout";
3 | }
4 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/obj/Debug/netcoreapp2.2/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/obj/Debug/netcoreapp2.2/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/obj/Debug/netcoreapp2.2/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/Debug/netcoreapp2.2/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/Debug/netcoreapp2.2/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/Debug/netcoreapp2.2/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.AssemblyInfoInputs.cache:
--------------------------------------------------------------------------------
1 | a1ef623e1378f3bf1ac751fca28bc76bf9b22a80
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/obj/Debug/netcoreapp2.0/content.AssemblyInfoInputs.cache:
--------------------------------------------------------------------------------
1 | a1ef623e1378f3bf1ac751fca28bc76bf9b22a80
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-console/content/obj/Debug/netcoreapp2.0/content.AssemblyInfoInputs.cache:
--------------------------------------------------------------------------------
1 | a1ef623e1378f3bf1ac751fca28bc76bf9b22a80
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/obj/Debug/netcoreapp2.0/content.AssemblyInfoInputs.cache:
--------------------------------------------------------------------------------
1 | a1ef623e1378f3bf1ac751fca28bc76bf9b22a80
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/Debug/netcoreapp2.2/webapi.RazorAssemblyInfo.cache:
--------------------------------------------------------------------------------
1 | f32384ad0d874b8b4ef80b835445d9ed41e1558b
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-console/content/obj/Debug/netcoreapp2.0/content.csproj.CoreCompileInputs.cache:
--------------------------------------------------------------------------------
1 | ee8a2c76356aba3aeccf8b64b632ef551bb842be
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.csproj.CoreCompileInputs.cache:
--------------------------------------------------------------------------------
1 | 6ab992b0702155f9aed1cf8c24919be354488f18
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/obj/Debug/netcoreapp2.0/content.csproj.CoreCompileInputs.cache:
--------------------------------------------------------------------------------
1 | ccecb293b5fc3f04a41e37e77b83384a401e2e23
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/obj/Debug/netcoreapp2.2/client.AssemblyInfoInputs.cache:
--------------------------------------------------------------------------------
1 | bf7784d7de989d2ff82b72894d57569fb689b395
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/Debug/netcoreapp2.2/webapi.AssemblyInfoInputs.cache:
--------------------------------------------------------------------------------
1 | e4c40253dd0b85da7072d0f4aed1390d65fe7e53
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/obj/Debug/netcoreapp2.0/content.csproj.CoreCompileInputs.cache:
--------------------------------------------------------------------------------
1 | 58f69ddca8ee9fb7c29bb330ea1fde5eba0c189d
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/obj/Debug/netcoreapp2.2/client.csproj.CoreCompileInputs.cache:
--------------------------------------------------------------------------------
1 | 60cfa23e2858227e728b3b9b4a0f5c38e3e44b05
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/Debug/netcoreapp2.2/webapi.csproj.CoreCompileInputs.cache:
--------------------------------------------------------------------------------
1 | 41365983f6d84658523bf6b085f17277038ecf32
2 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Views/_ViewImports.cshtml:
--------------------------------------------------------------------------------
1 | @using content
2 | @using content.Models
3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "LogLevel": {
5 | "Default": "Warning"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Warning"
5 | }
6 | },
7 | "AllowedHosts": "*"
8 | }
9 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-mvcapp/content/wwwroot/favicon.ico
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/obj/content.csproj.nuget.cache:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "dgSpecHash": "ghpKrup4XlUKuOme85A30am1op+qKU7Ari/YRKnDinZmNPUEZDCbjEajUU/9ZUQTJDL/fX8hbXsAU77y526mjA==",
4 | "success": true
5 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/obj/content.csproj.nuget.cache:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "dgSpecHash": "m/ukdauHqEpkHuQiLi5O/2fgyGPKzOeHAbVsqU3aybuKKavEl3282Igic+FyD8bPH4XUrhHUI2z5YUCFmJxiMA==",
4 | "success": true
5 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-console/content/obj/content.csproj.nuget.cache:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "dgSpecHash": "j1/hXnlc+tiwLH5YfUGn23OwVeP8901S4wvLRrzzfx5uAgkaxAQfWO2nYrmasS4iDRrAp28Eq+zlE9GPUWcLww==",
4 | "success": true
5 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/bin/Debug/netcoreapp2.0/content.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-mvcapp/content/bin/Debug/netcoreapp2.0/content.dll
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/bin/Debug/netcoreapp2.0/content.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-mvcapp/content/bin/Debug/netcoreapp2.0/content.pdb
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.dll
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.pdb
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/obj/content.csproj.nuget.cache:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "dgSpecHash": "VYwoU3vEZIVcsAuTsz0+GAIzcCeIUCAMCKHSo/GsgHdWepPi7L4Wsz515VeM7v2jfFeMRDo4UG2IVcNdbDG1dQ==",
4 | "success": true
5 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/bin/Debug/netcoreapp2.0/content.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-webapp/content/bin/Debug/netcoreapp2.0/content.dll
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/bin/Debug/netcoreapp2.0/content.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-webapp/content/bin/Debug/netcoreapp2.0/content.pdb
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/obj/Debug/netcoreapp2.0/content.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-webapp/content/obj/Debug/netcoreapp2.0/content.dll
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/obj/Debug/netcoreapp2.0/content.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-webapp/content/obj/Debug/netcoreapp2.0/content.pdb
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/obj/client.csproj.nuget.cache:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "dgSpecHash": "Dc51AGIvrmimoMnExdFYX8d7SQ5Q4ENlJRFOmZWdA/3WSfLXmX4Rrf3/1AstmIGpvjqkS7+djh/1CjG4FKh3pw==",
4 | "success": true
5 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/webapi.csproj.nuget.cache:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "dgSpecHash": "BIAA9ShV3vsawTsMm55HLuOt/PZlE49h9pi2tr+O/9Lu1W4q381ZvEk/z2/E9L9Jweadat3qeWti31CK05EfAw==",
4 | "success": true
5 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Views/Home/About.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "About";
3 | }
4 |
@ViewData["Title"]
5 | @ViewData["Message"]
6 |
7 | Use this area to provide additional information.
8 |
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/bin/Debug/netcoreapp2.0/content.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-serviceapp/content/bin/Debug/netcoreapp2.0/content.dll
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/bin/Debug/netcoreapp2.0/content.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-serviceapp/content/bin/Debug/netcoreapp2.0/content.pdb
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/obj/Debug/netcoreapp2.0/content.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-serviceapp/content/obj/Debug/netcoreapp2.0/content.dll
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/obj/Debug/netcoreapp2.0/content.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-serviceapp/content/obj/Debug/netcoreapp2.0/content.pdb
--------------------------------------------------------------------------------
/dotnetcore-graph-console/content/obj/Debug/netcoreapp2.0/content.assets.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-console/content/obj/Debug/netcoreapp2.0/content.assets.cache
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.assets.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.assets.cache
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/obj/Debug/netcoreapp2.0/content.assets.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-webapp/content/obj/Debug/netcoreapp2.0/content.assets.cache
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/chenxizhang.dotnetcore.msgraph.mvcapp.CSharp.1.0.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-mvcapp/chenxizhang.dotnetcore.msgraph.mvcapp.CSharp.1.0.0.nupkg
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Helpers/IGrahpSDKHelper.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using Microsoft.Graph;
3 | public interface IGraphSDKHelper
4 | {
5 | GraphServiceClient GetServiceClient(string identifier,HttpContext context);
6 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/obj/Debug/netcoreapp2.0/content.assets.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-serviceapp/content/obj/Debug/netcoreapp2.0/content.assets.cache
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/chenxizhang.dotnetcore.msgraph.webapi.CSharp.1.0.2.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-webapi/chenxizhang.dotnetcore.msgraph.webapi.CSharp.1.0.2.nupkg
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Debug",
5 | "System": "Information",
6 | "Microsoft": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/chenxizhang.dotnetcore.msgraph.webapp.CSharp.1.0.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-webapp/chenxizhang.dotnetcore.msgraph.webapp.CSharp.1.0.0.nupkg
--------------------------------------------------------------------------------
/dotnetcore-graph-console/chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-console/chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.0.nupkg
--------------------------------------------------------------------------------
/dotnetcore-graph-console/chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.1.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-console/chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.1.nupkg
--------------------------------------------------------------------------------
/dotnetcore-graph-console/chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.2.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-console/chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.2.nupkg
--------------------------------------------------------------------------------
/dotnetcore-graph-console/chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.3.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-console/chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.3.nupkg
--------------------------------------------------------------------------------
/dotnetcore-graph-console/chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.4.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-console/chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.4.nupkg
--------------------------------------------------------------------------------
/dotnetcore-graph-console/chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.5.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-console/chenxizhang.dotnetcore.msgraph.console.CSharp.1.0.5.nupkg
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/obj/Debug/netcoreapp2.2/client.assets.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-webapi/content/client/obj/Debug/netcoreapp2.2/client.assets.cache
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/Debug/netcoreapp2.2/webapi.assets.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-webapi/content/webapi/obj/Debug/netcoreapp2.2/webapi.assets.cache
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/bin/Debug/netcoreapp2.0/content.runtimeconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtimeOptions": {
3 | "tfm": "netcoreapp2.0",
4 | "framework": {
5 | "name": "Microsoft.NETCore.App",
6 | "version": "2.0.0"
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/chenxizhang.dotnetcore.msgraph.serviceapp.CSharp.1.0.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-serviceapp/chenxizhang.dotnetcore.msgraph.serviceapp.CSharp.1.0.0.nupkg
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/chenxizhang.dotnetcore.msgraph.serviceapp.CSharp.1.0.1.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-serviceapp/chenxizhang.dotnetcore.msgraph.serviceapp.CSharp.1.0.1.nupkg
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | dotnetcore-graph-serviceapp/content/obj/Debug/netcoreapp2.0/content.csproj.CoreCompileInputs.cache
2 | dotnetcore-graph-console/content/obj/Debug/netcoreapp2.0/content.csproj.CoreCompileInputs.cache
3 | dotnetcore-graph-console/content/obj/project.assets.json
4 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "IncludeScopes": false,
4 | "LogLevel": {
5 | "Default": "Debug",
6 | "System": "Information",
7 | "Microsoft": "Information"
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/dotnetcore-graph-console/content/obj/Debug/netcoreapp2.0/content.csprojAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-console/content/obj/Debug/netcoreapp2.0/content.csprojAssemblyReference.cache
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.csprojAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.csprojAssemblyReference.cache
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-mvcapp/content/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-mvcapp/content/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.csprojResolveAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.csprojResolveAssemblyReference.cache
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-mvcapp/content/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-mvcapp/content/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/obj/Debug/netcoreapp2.2/client.csprojAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-webapi/content/client/obj/Debug/netcoreapp2.2/client.csprojAssemblyReference.cache
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/Debug/netcoreapp2.2/webapi.csprojAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Office365DevOps/dotnetcore-office365dev-templates-msgraph/HEAD/dotnetcore-graph-webapi/content/webapi/obj/Debug/netcoreapp2.2/webapi.csprojAssemblyReference.cache
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Models/ErrorViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace content.Models
4 | {
5 | public class ErrorViewModel
6 | {
7 | public string RequestId { get; set; }
8 |
9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
10 | }
11 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/obj/Debug/netcoreapp2.2/project.razor.json:
--------------------------------------------------------------------------------
1 | {
2 | "ProjectFilePath": "c:\\Users\\arechen\\dotnetcore-office365dev-templates\\dotnetcore-graph-webapi\\content\\client\\client.csproj",
3 | "TargetFramework": "netcoreapp2.2",
4 | "TagHelpers": [],
5 | "Configuration": null
6 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Helpers/GraphSettings.cs:
--------------------------------------------------------------------------------
1 | public class GraphSettings{
2 |
3 | public string Authority { get; set; }
4 | public string Resource { get; set; }
5 |
6 | public string Version { get; set; }
7 |
8 | public string ClientId { get; set; }
9 | public string Secret { get; set; }
10 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/css/site.min.css:
--------------------------------------------------------------------------------
1 | body{padding-top:50px;padding-bottom:20px}.body-content{padding-left:15px;padding-right:15px}.carousel-caption p{font-size:20px;line-height:1.4}.carousel-inner .item img[src$=".svg"]{width:100%}#qrCode{margin:15px}@media screen and (max-width:767px){.carousel-caption{display:none}}
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/bin/Debug/netcoreapp2.0/content.runtimeconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtimeOptions": {
3 | "tfm": "netcoreapp2.0",
4 | "framework": {
5 | "name": "Microsoft.NETCore.App",
6 | "version": "2.0.0"
7 | },
8 | "configProperties": {
9 | "System.GC.Server": true
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/bin/Debug/netcoreapp2.0/content.runtimeconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtimeOptions": {
3 | "tfm": "netcoreapp2.0",
4 | "framework": {
5 | "name": "Microsoft.NETCore.App",
6 | "version": "2.0.0"
7 | },
8 | "configProperties": {
9 | "System.GC.Server": true
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/bin/Debug/netcoreapp2.0/content.runtimeconfig.dev.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtimeOptions": {
3 | "additionalProbingPaths": [
4 | "C:\\Users\\arechen\\.dotnet\\store\\|arch|\\|tfm|",
5 | "C:\\Users\\arechen\\.nuget\\packages",
6 | "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
7 | ]
8 | }
9 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/bin/Debug/netcoreapp2.0/content.runtimeconfig.dev.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtimeOptions": {
3 | "additionalProbingPaths": [
4 | "C:\\Users\\arechen\\.dotnet\\store\\|arch|\\|tfm|",
5 | "C:\\Users\\arechen\\.nuget\\packages",
6 | "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
7 | ]
8 | }
9 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/bin/Debug/netcoreapp2.0/content.runtimeconfig.dev.json:
--------------------------------------------------------------------------------
1 | {
2 | "runtimeOptions": {
3 | "additionalProbingPaths": [
4 | "C:\\Users\\arechen\\.dotnet\\store\\|arch|\\|tfm|",
5 | "C:\\Users\\arechen\\.nuget\\packages",
6 | "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
7 | ]
8 | }
9 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/dotnetcore-graph-console/content/content.csproj"
11 | ],
12 | "problemMatcher": "$msCompile"
13 | }
14 | ]
15 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-console/content/content.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/content.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | netcoreapp2.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/project.razor.json:
--------------------------------------------------------------------------------
1 | {
2 | "ProjectFilePath": "c:\\Users\\arechen\\dotnetcore-office365dev-templates\\dotnetcore-graph-mvcapp\\content\\content.csproj",
3 | "TargetFramework": "netcoreapp2.0",
4 | "TagHelpers": [],
5 | "Configuration": {
6 | "ConfigurationName": "MVC-2.0",
7 | "LanguageVersion": "2.0",
8 | "Extensions": [
9 | {
10 | "ExtensionName": "MVC-2.0"
11 | }
12 | ]
13 | }
14 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/obj/Debug/netcoreapp2.0/project.razor.json:
--------------------------------------------------------------------------------
1 | {
2 | "ProjectFilePath": "c:\\Users\\arechen\\dotnetcore-office365dev-templates\\dotnetcore-graph-webapp\\content\\content.csproj",
3 | "TargetFramework": "netcoreapp2.0",
4 | "TagHelpers": [],
5 | "Configuration": {
6 | "ConfigurationName": "MVC-2.0",
7 | "LanguageVersion": "2.0",
8 | "Extensions": [
9 | {
10 | "ExtensionName": "MVC-2.0"
11 | }
12 | ]
13 | }
14 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/Debug/netcoreapp2.2/project.razor.json:
--------------------------------------------------------------------------------
1 | {
2 | "ProjectFilePath": "c:\\Users\\arechen\\dotnetcore-office365dev-templates\\dotnetcore-graph-webapi\\content\\webapi\\webapi.csproj",
3 | "TargetFramework": "netcoreapp2.2",
4 | "TagHelpers": [],
5 | "Configuration": {
6 | "ConfigurationName": "MVC-2.1",
7 | "LanguageVersion": "2.1",
8 | "Extensions": [
9 | {
10 | "ExtensionName": "MVC-2.1"
11 | }
12 | ]
13 | }
14 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-console/content/obj/Debug/netcoreapp2.0/project.razor.json:
--------------------------------------------------------------------------------
1 | {
2 | "ProjectFilePath": "c:\\Users\\arechen\\dotnetcore-office365dev-templates\\dotnetcore-graph-console\\content\\content.csproj",
3 | "TargetFramework": "netcoreapp2.0",
4 | "TagHelpers": [],
5 | "Configuration": {
6 | "ConfigurationName": "UnsupportedRazor",
7 | "LanguageVersion": "1.0",
8 | "Extensions": [
9 | {
10 | "ExtensionName": "UnsupportedRazorExtension"
11 | }
12 | ]
13 | }
14 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/obj/Debug/netcoreapp2.0/project.razor.json:
--------------------------------------------------------------------------------
1 | {
2 | "ProjectFilePath": "c:\\Users\\arechen\\dotnetcore-office365dev-templates\\dotnetcore-graph-serviceapp\\content\\content.csproj",
3 | "TargetFramework": "netcoreapp2.0",
4 | "TagHelpers": [],
5 | "Configuration": {
6 | "ConfigurationName": "UnsupportedRazor",
7 | "LanguageVersion": "1.0",
8 | "Extensions": [
9 | {
10 | "ExtensionName": "UnsupportedRazorExtension"
11 | }
12 | ]
13 | }
14 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | chenxizhang.dotnetcore.msgraph.webapp.CSharp
5 | 1.0.0
6 |
7 | web application using Microsoft Graph。这是一个访问Graph API的网站模板。
8 |
9 | Ares Chen | 陈希章
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dotnetcore-graph-console/content.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | chenxizhang.dotnetcore.msgraph.console.CSharp
5 | 1.0.5
6 |
7 | Console application using Microsoft Graph。这是一个访问Graph API的控制台程序模板。
8 |
9 | Ares Chen | 陈希章
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | chenxizhang.dotnetcore.msgraph.mvcapp.CSharp
5 | 1.0.0
6 |
7 | Web mvc application using Microsoft Graph。这是一个访问Graph API的MVC网站模板。
8 |
9 | Ares Chen | 陈希章
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Views/Home/Contact.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "Contact";
3 | }
4 | @ViewData["Title"]
5 | @ViewData["Message"]
6 |
7 |
8 | One Microsoft Way
9 | Redmond, WA 98052-6399
10 | P:
11 | 425.555.0100
12 |
13 |
14 |
15 | Support: Support@example.com
16 | Marketing: Marketing@example.com
17 |
18 |
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | chenxizhang.dotnetcore.msgraph.serviceapp.CSharp
5 | 1.0.1
6 |
7 | Service application using Microsoft Graph。这是一个访问Graph API的无人值守应用程序(通常是一个服务)模板。
8 |
9 | Ares Chen | 陈希章
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | chenxizhang.dotnetcore.msgraph.webapi.CSharp
5 | 1.0.2
6 |
7 | web api application using Microsoft Graph。这是一个访问Graph API的web api模板,而且实现了从客户端到服务层的on-behalfof 访问流。
8 |
9 | Ares Chen | 陈希章
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/lib/bootstrap/dist/js/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/content.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/content.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/webapi.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.2
5 | InProcess
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/lib/jquery/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery",
3 | "main": "dist/jquery.js",
4 | "license": "MIT",
5 | "ignore": [
6 | "package.json"
7 | ],
8 | "keywords": [
9 | "jquery",
10 | "javascript",
11 | "browser",
12 | "library"
13 | ],
14 | "homepage": "https://github.com/jquery/jquery-dist",
15 | "version": "2.2.0",
16 | "_release": "2.2.0",
17 | "_resolution": {
18 | "type": "version",
19 | "tag": "2.2.0",
20 | "commit": "6fc01e29bdad0964f62ef56d01297039cdcadbe5"
21 | },
22 | "_source": "git://github.com/jquery/jquery-dist.git",
23 | "_target": "2.2.0",
24 | "_originalSource": "jquery"
25 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.Extensions.Configuration;
9 | using Microsoft.Extensions.Logging;
10 |
11 | namespace content
12 | {
13 | public class Program
14 | {
15 | public static void Main(string[] args)
16 | {
17 | BuildWebHost(args).Run();
18 | }
19 |
20 | public static IWebHost BuildWebHost(string[] args) =>
21 | WebHost.CreateDefaultBuilder(args)
22 | .UseStartup()
23 | .Build();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.Extensions.Configuration;
9 | using Microsoft.Extensions.Logging;
10 |
11 | namespace content
12 | {
13 | public class Program
14 | {
15 | public static void Main(string[] args)
16 | {
17 | BuildWebHost(args).Run();
18 | }
19 |
20 | public static IWebHost BuildWebHost(string[] args) =>
21 | WebHost.CreateDefaultBuilder(args)
22 | .UseStartup()
23 | .Build();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/bundleconfig.json:
--------------------------------------------------------------------------------
1 | // Configure bundling and minification for the project.
2 | // More info at https://go.microsoft.com/fwlink/?LinkId=808241
3 | [
4 | {
5 | "outputFileName": "wwwroot/css/site.min.css",
6 | // An array of relative input file paths. Globbing patterns supported
7 | "inputFiles": [
8 | "wwwroot/css/site.css"
9 | ]
10 | },
11 | {
12 | "outputFileName": "wwwroot/js/site.min.js",
13 | "inputFiles": [
14 | "wwwroot/js/site.js"
15 | ],
16 | // Optionally specify minification options
17 | "minify": {
18 | "enabled": true,
19 | "renameLocals": true
20 | },
21 | // Optionally generate .map file
22 | "sourceMap": false
23 | }
24 | ]
25 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.Extensions.Configuration;
9 | using Microsoft.Extensions.Logging;
10 |
11 | namespace webapi
12 | {
13 | public class Program
14 | {
15 | public static void Main(string[] args)
16 | {
17 | CreateWebHostBuilder(args).Build().Run();
18 | }
19 |
20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
21 | WebHost.CreateDefaultBuilder(args)
22 | .UseStartup();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/css/site.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding-top: 50px;
3 | padding-bottom: 20px;
4 | }
5 |
6 | /* Wrapping element */
7 | /* Set some basic padding to keep content from hitting the edges */
8 | .body-content {
9 | padding-left: 15px;
10 | padding-right: 15px;
11 | }
12 |
13 | /* Carousel */
14 | .carousel-caption p {
15 | font-size: 20px;
16 | line-height: 1.4;
17 | }
18 |
19 | /* Make .svg files in the carousel display properly in older browsers */
20 | .carousel-inner .item img[src$=".svg"] {
21 | width: 100%;
22 | }
23 |
24 | /* QR code generator */
25 | #qrCode {
26 | margin: 15px;
27 | }
28 |
29 | /* Hide/rearrange for smaller screens */
30 | @media screen and (max-width: 767px) {
31 | /* Hide captions */
32 | .carousel-caption {
33 | display: none;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/Debug/netcoreapp2.2/webapi.RazorAssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | using System;
12 | using System.Reflection;
13 |
14 | [assembly: Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute("webapi.Views")]
15 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorLanguageVersionAttribute("2.1")]
16 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorConfigurationNameAttribute("MVC-2.1")]
17 | [assembly: Microsoft.AspNetCore.Razor.Hosting.RazorExtensionAssemblyNameAttribute("MVC-2.1", "Microsoft.AspNetCore.Mvc.Razor.Extensions")]
18 |
19 | // 由 MSBuild WriteCodeFragment 类生成。
20 |
21 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:38019",
8 | "sslPort": 44343
9 | }
10 | },
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "api/values",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "webapi": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "api/values",
24 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
25 | "environmentVariables": {
26 | "ASPNETCORE_ENVIRONMENT": "Development"
27 | }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Views/Shared/Error.cshtml:
--------------------------------------------------------------------------------
1 | @model ErrorViewModel
2 | @{
3 | ViewData["Title"] = "Error";
4 | }
5 |
6 | Error.
7 | An error occurred while processing your request.
8 |
9 | @if (Model.ShowRequestId)
10 | {
11 |
12 | Request ID: @Model.RequestId
13 |
14 | }
15 |
16 | Development Mode
17 |
18 | Swapping to Development environment will display more detailed information about the error that occurred.
19 |
20 |
21 | Development environment should not be enabled in deployed applications , as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development , and restarting the application.
22 |
23 |
--------------------------------------------------------------------------------
/dotnetcore-graph-console/content/obj/Debug/netcoreapp2.0/content.AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | using System;
12 | using System.Reflection;
13 |
14 | [assembly: System.Reflection.AssemblyCompanyAttribute("content")]
15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
18 | [assembly: System.Reflection.AssemblyProductAttribute("content")]
19 | [assembly: System.Reflection.AssemblyTitleAttribute("content")]
20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
21 |
22 | // 由 MSBuild WriteCodeFragment 类生成。
23 |
24 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/obj/Debug/netcoreapp2.2/client.AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | using System;
12 | using System.Reflection;
13 |
14 | [assembly: System.Reflection.AssemblyCompanyAttribute("client")]
15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
18 | [assembly: System.Reflection.AssemblyProductAttribute("client")]
19 | [assembly: System.Reflection.AssemblyTitleAttribute("client")]
20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
21 |
22 | // 由 MSBuild WriteCodeFragment 类生成。
23 |
24 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/Debug/netcoreapp2.2/webapi.AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | using System;
12 | using System.Reflection;
13 |
14 | [assembly: System.Reflection.AssemblyCompanyAttribute("webapi")]
15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
18 | [assembly: System.Reflection.AssemblyProductAttribute("webapi")]
19 | [assembly: System.Reflection.AssemblyTitleAttribute("webapi")]
20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
21 |
22 | // 由 MSBuild WriteCodeFragment 类生成。
23 |
24 |
--------------------------------------------------------------------------------
/dotnetcore-graph-console/content/obj/content.csproj.nuget.g.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/obj/content.csproj.nuget.g.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/obj/client.csproj.nuget.g.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/lib/jquery-validation/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-validation",
3 | "homepage": "http://jqueryvalidation.org/",
4 | "repository": {
5 | "type": "git",
6 | "url": "git://github.com/jzaefferer/jquery-validation.git"
7 | },
8 | "authors": [
9 | "Jörn Zaefferer "
10 | ],
11 | "description": "Form validation made easy",
12 | "main": "dist/jquery.validate.js",
13 | "keywords": [
14 | "forms",
15 | "validation",
16 | "validate"
17 | ],
18 | "license": "MIT",
19 | "ignore": [
20 | "**/.*",
21 | "node_modules",
22 | "bower_components",
23 | "test",
24 | "demo",
25 | "lib"
26 | ],
27 | "dependencies": {
28 | "jquery": ">= 1.7.2"
29 | },
30 | "version": "1.14.0",
31 | "_release": "1.14.0",
32 | "_resolution": {
33 | "type": "version",
34 | "tag": "1.14.0",
35 | "commit": "c1343fb9823392aa9acbe1c3ffd337b8c92fed48"
36 | },
37 | "_source": "git://github.com/jzaefferer/jquery-validation.git",
38 | "_target": ">=1.8",
39 | "_originalSource": "jquery-validation"
40 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | using System;
12 | using System.Reflection;
13 |
14 | [assembly: System.Reflection.AssemblyCompanyAttribute("content")]
15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
18 | [assembly: System.Reflection.AssemblyProductAttribute("content")]
19 | [assembly: System.Reflection.AssemblyTitleAttribute("content")]
20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
21 |
22 | // Generated by the MSBuild WriteCodeFragment class.
23 |
24 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/obj/Debug/netcoreapp2.0/content.AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | using System;
12 | using System.Reflection;
13 |
14 | [assembly: System.Reflection.AssemblyCompanyAttribute("content")]
15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
18 | [assembly: System.Reflection.AssemblyProductAttribute("content")]
19 | [assembly: System.Reflection.AssemblyTitleAttribute("content")]
20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
21 |
22 | // Generated by the MSBuild WriteCodeFragment class.
23 |
24 |
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/obj/Debug/netcoreapp2.0/content.AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | using System;
12 | using System.Reflection;
13 |
14 | [assembly: System.Reflection.AssemblyCompanyAttribute("content")]
15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
18 | [assembly: System.Reflection.AssemblyProductAttribute("content")]
19 | [assembly: System.Reflection.AssemblyTitleAttribute("content")]
20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
21 |
22 | // Generated by the MSBuild WriteCodeFragment class.
23 |
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Ares Chen 陈希章
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/lib/bootstrap/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bootstrap",
3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.",
4 | "keywords": [
5 | "css",
6 | "js",
7 | "less",
8 | "mobile-first",
9 | "responsive",
10 | "front-end",
11 | "framework",
12 | "web"
13 | ],
14 | "homepage": "http://getbootstrap.com",
15 | "license": "MIT",
16 | "moduleType": "globals",
17 | "main": [
18 | "less/bootstrap.less",
19 | "dist/js/bootstrap.js"
20 | ],
21 | "ignore": [
22 | "/.*",
23 | "_config.yml",
24 | "CNAME",
25 | "composer.json",
26 | "CONTRIBUTING.md",
27 | "docs",
28 | "js/tests",
29 | "test-infra"
30 | ],
31 | "dependencies": {
32 | "jquery": "1.9.1 - 3"
33 | },
34 | "version": "3.3.7",
35 | "_release": "3.3.7",
36 | "_resolution": {
37 | "type": "version",
38 | "tag": "v3.3.7",
39 | "commit": "0b9c4a4007c44201dce9a6cc1a38407005c26c86"
40 | },
41 | "_source": "https://github.com/twbs/bootstrap.git",
42 | "_target": "v3.3.7",
43 | "_originalSource": "bootstrap",
44 | "_direct": true
45 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/lib/bootstrap/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2011-2016 Twitter, Inc.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/lib/jquery-validation/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | =====================
3 |
4 | Copyright Jörn Zaefferer
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Views/Shared/_ValidationScriptsPartial.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
12 |
18 |
19 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/lib/jquery-validation-unobtrusive/.bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery-validation-unobtrusive",
3 | "version": "3.2.6",
4 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive",
5 | "description": "Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.",
6 | "main": [
7 | "jquery.validate.unobtrusive.js"
8 | ],
9 | "ignore": [
10 | "**/.*",
11 | "*.json",
12 | "*.md",
13 | "*.txt",
14 | "gulpfile.js"
15 | ],
16 | "keywords": [
17 | "jquery",
18 | "asp.net",
19 | "mvc",
20 | "validation",
21 | "unobtrusive"
22 | ],
23 | "authors": [
24 | "Microsoft"
25 | ],
26 | "license": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm",
27 | "repository": {
28 | "type": "git",
29 | "url": "git://github.com/aspnet/jquery-validation-unobtrusive.git"
30 | },
31 | "dependencies": {
32 | "jquery-validation": ">=1.8",
33 | "jquery": ">=1.8"
34 | },
35 | "_release": "3.2.6",
36 | "_resolution": {
37 | "type": "version",
38 | "tag": "v3.2.6",
39 | "commit": "13386cd1b5947d8a5d23a12b531ce3960be1eba7"
40 | },
41 | "_source": "git://github.com/aspnet/jquery-validation-unobtrusive.git",
42 | "_target": "3.2.6",
43 | "_originalSource": "jquery-validation-unobtrusive"
44 | }
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": ".NET Core Launch (console)",
9 | "type": "coreclr",
10 | "request": "launch",
11 | "preLaunchTask": "build",
12 | // If you have changed target frameworks, make sure to update the program path.
13 | "program": "${workspaceFolder}/dotnetcore-graph-console/content/bin/Debug/netcoreapp2.0/content.dll",
14 | "args": [],
15 | "cwd": "${workspaceFolder}/dotnetcore-graph-console/content",
16 | // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
17 | "console": "internalConsole",
18 | "stopAtEntry": false,
19 | "internalConsoleOptions": "openOnSessionStart"
20 | },
21 | {
22 | "name": ".NET Core Attach",
23 | "type": "coreclr",
24 | "request": "attach",
25 | "processId": "${command:pickProcess}"
26 | }
27 | ,]
28 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/obj/Debug/netcoreapp2.0/content.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-mvcapp\content\obj\Debug\netcoreapp2.0\content.csproj.CoreCompileInputs.cache
2 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-mvcapp\content\obj\Debug\netcoreapp2.0\content.AssemblyInfoInputs.cache
3 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-mvcapp\content\obj\Debug\netcoreapp2.0\content.AssemblyInfo.cs
4 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-mvcapp\content\bin\Debug\netcoreapp2.0\content.deps.json
5 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-mvcapp\content\bin\Debug\netcoreapp2.0\content.runtimeconfig.json
6 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-mvcapp\content\bin\Debug\netcoreapp2.0\content.runtimeconfig.dev.json
7 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-mvcapp\content\bin\Debug\netcoreapp2.0\content.dll
8 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-mvcapp\content\bin\Debug\netcoreapp2.0\content.pdb
9 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-mvcapp\content\obj\Debug\netcoreapp2.0\content.dll
10 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-mvcapp\content\obj\Debug\netcoreapp2.0\content.pdb
11 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/obj/Debug/netcoreapp2.0/content.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-webapp\content\bin\Debug\netcoreapp2.0\content.deps.json
2 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-webapp\content\bin\Debug\netcoreapp2.0\content.runtimeconfig.json
3 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-webapp\content\bin\Debug\netcoreapp2.0\content.runtimeconfig.dev.json
4 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-webapp\content\bin\Debug\netcoreapp2.0\content.dll
5 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-webapp\content\bin\Debug\netcoreapp2.0\content.pdb
6 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-webapp\content\obj\Debug\netcoreapp2.0\content.csproj.CoreCompileInputs.cache
7 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-webapp\content\obj\Debug\netcoreapp2.0\content.AssemblyInfoInputs.cache
8 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-webapp\content\obj\Debug\netcoreapp2.0\content.AssemblyInfo.cs
9 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-webapp\content\obj\Debug\netcoreapp2.0\content.dll
10 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-webapp\content\obj\Debug\netcoreapp2.0\content.pdb
11 |
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/obj/Debug/netcoreapp2.0/content.csproj.FileListAbsolute.txt:
--------------------------------------------------------------------------------
1 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-serviceapp\content\bin\Debug\netcoreapp2.0\content.deps.json
2 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-serviceapp\content\bin\Debug\netcoreapp2.0\content.runtimeconfig.json
3 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-serviceapp\content\bin\Debug\netcoreapp2.0\content.runtimeconfig.dev.json
4 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-serviceapp\content\bin\Debug\netcoreapp2.0\content.dll
5 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-serviceapp\content\bin\Debug\netcoreapp2.0\content.pdb
6 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-serviceapp\content\obj\Debug\netcoreapp2.0\content.csproj.CoreCompileInputs.cache
7 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-serviceapp\content\obj\Debug\netcoreapp2.0\content.AssemblyInfoInputs.cache
8 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-serviceapp\content\obj\Debug\netcoreapp2.0\content.AssemblyInfo.cs
9 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-serviceapp\content\obj\Debug\netcoreapp2.0\content.dll
10 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-serviceapp\content\obj\Debug\netcoreapp2.0\content.pdb
11 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Helpers/GraphSDKHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Net.Http.Headers;
2 | using System.Threading.Tasks;
3 | using Microsoft.AspNetCore.Http;
4 | using Microsoft.Extensions.Caching.Memory;
5 | using Microsoft.Extensions.DependencyInjection;
6 | using Microsoft.Graph;
7 | using Microsoft.IdentityModel.Clients.ActiveDirectory;
8 |
9 |
10 | public class GraphSDKHelper : IGraphSDKHelper
11 | {
12 | private GraphSettings settings;
13 | public GraphSDKHelper(GraphSettings _settings)
14 | {
15 | settings = _settings;
16 | }
17 | public GraphServiceClient GetServiceClient(string identifier, HttpContext context)
18 | {
19 | var memorycache = context.RequestServices.GetRequiredService();
20 | var sessionTokencache = new SessionTokenCache(identifier, memorycache);
21 | var ctx = new AuthenticationContext(settings.Authority, sessionTokencache.GetCacheInstance());
22 | var result = ctx.AcquireTokenSilentAsync(settings.Resource, new ClientCredential(settings.ClientId, settings.Secret), new UserIdentifier(identifier, UserIdentifierType.UniqueId)).Result;
23 |
24 | var graphserviceClient = new GraphServiceClient(new DelegateAuthenticationProvider(async (request) =>
25 | {
26 | request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);
27 | await Task.FromResult(0);
28 | }))
29 | {
30 | BaseUrl = $"{settings.Resource}/{settings.Version}"
31 | };
32 |
33 | return graphserviceClient;
34 | }
35 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/obj/client.csproj.nuget.g.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | True
5 | NuGet
6 | C:\temp\dotnetcore-graph-webapi\content\client\obj\project.assets.json
7 | $(UserProfile)\.nuget\packages\
8 | C:\Users\arechen\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder
9 | PackageReference
10 | 4.9.2
11 |
12 |
13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/obj/content.csproj.nuget.g.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | True
5 | NuGet
6 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-mvcapp\content\obj\project.assets.json
7 | $(UserProfile)\.nuget\packages\
8 | C:\Users\arechen\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder
9 | PackageReference
10 | 4.6.2
11 |
12 |
13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/obj/content.csproj.nuget.g.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | True
5 | NuGet
6 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-webapp\content\obj\project.assets.json
7 | $(UserProfile)\.nuget\packages\
8 | C:\Users\arechen\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder
9 | PackageReference
10 | 4.6.2
11 |
12 |
13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/dotnetcore-graph-console/content/obj/content.csproj.nuget.g.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | True
5 | NuGet
6 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-console\content\obj\project.assets.json
7 | $(UserProfile)\.nuget\packages\
8 | C:\Users\arechen\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder
9 | PackageReference
10 | 4.6.2
11 |
12 |
13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/obj/content.csproj.nuget.g.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | True
5 | NuGet
6 | C:\Users\arechen\dotnetcore-office365dev-templates\dotnetcore-graph-serviceapp\content\obj\project.assets.json
7 | $(UserProfile)\.nuget\packages\
8 | C:\Users\arechen\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder
9 | PackageReference
10 | 4.6.2
11 |
12 |
13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/lib/jquery/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright jQuery Foundation and other contributors, https://jquery.org/
2 |
3 | This software consists of voluntary contributions made by many
4 | individuals. For exact contribution history, see the revision history
5 | available at https://github.com/jquery/jquery
6 |
7 | The following license applies to all parts of this software except as
8 | documented below:
9 |
10 | ====
11 |
12 | Permission is hereby granted, free of charge, to any person obtaining
13 | a copy of this software and associated documentation files (the
14 | "Software"), to deal in the Software without restriction, including
15 | without limitation the rights to use, copy, modify, merge, publish,
16 | distribute, sublicense, and/or sell copies of the Software, and to
17 | permit persons to whom the Software is furnished to do so, subject to
18 | the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be
21 | included in all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 |
31 | ====
32 |
33 | All files located in the node_modules and external directories are
34 | externally maintained libraries used by this software which have their
35 | own licenses; we recommend you read them, as their terms may differ from
36 | the terms above.
37 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/client/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.Http.Headers;
3 | using System.Threading.Tasks;
4 | using Microsoft.IdentityModel.Clients.ActiveDirectory;
5 | using System.Net.Http;
6 | using System.Collections.Generic;
7 |
8 | namespace clientapp
9 | {
10 | class Program
11 | {
12 | static void Main(string[] args)
13 | {
14 | #region parameters
15 | string authority, resource, deviceloginaddr;
16 | //#if(instance=="global")
17 | authority = "https://login.microsoftonline.com/common";
18 | resource = "https://office365devlabs.onmicrosoft.com/TodoListService-OBO";
19 | deviceloginaddr = "https://aka.ms/devicelogin";
20 | //#else
21 | authority = "https://login.chinacloudapi.cn/common";
22 | resource = "https://modtsp.partner.onmschina.cn/dotnet-obo-webapi";
23 | deviceloginaddr = "https://aka.ms/gallatindevicelogin";
24 | //#endif
25 | #endregion
26 |
27 | var ctx = new AuthenticationContext(authority: authority);
28 | var deviceCode = ctx.AcquireDeviceCodeAsync(resource, "{{obo-console-clientid}}").Result;
29 |
30 | Console.WriteLine($"请打开浏览器,访问 {deviceloginaddr} ,并以 {deviceCode.UserCode} 登陆");
31 | var result = ctx.AcquireTokenByDeviceCodeAsync(deviceCode).Result;
32 |
33 |
34 |
35 | var httpClient = new HttpClient();
36 | httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);
37 |
38 | // Call the To Do list service.
39 | HttpResponseMessage response = httpClient.GetAsync("http://localhost:5000/api/values").Result;
40 | Console.WriteLine(response.Content.ReadAsStringAsync().Result);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/dotnetcore-graph-console/content/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Ares Chen | 陈希章",
4 | "classifications": [
5 | "Common",
6 | "Console"
7 | ],
8 | "identity": "chenxizhang.dotnetcore.msgraph.console.CSharp",
9 | "name": "Console application using Microsoft Graph",
10 | "groupIdentity": "chenxizhang.dotnetcore.msgraph.console",
11 | "shortName": "graphconsole",
12 | "sourceName": "content",
13 | "primaryOutputs": [
14 | {
15 | "path": "content.csproj"
16 | }
17 | ],
18 | "tags": {
19 | "language": "C#",
20 | "type": "project"
21 | },
22 | "postActions": [
23 | {
24 | "description": "dotnet restore",
25 | "manualInstructions": [
26 | {
27 | "text": "Run 'dotnet restore'"
28 | }
29 | ],
30 | "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
31 | "continueOnError": true
32 | }
33 | ],
34 | "symbols": {
35 | "instance": {
36 | "type": "parameter",
37 | "datatype": "choice",
38 | "choices": [
39 | {
40 | "choice": "global"
41 | },
42 | {
43 | "choice": "gallatin"
44 | }
45 | ],
46 | "defaultValue": "global"
47 | },
48 | "clientid": {
49 | "type": "parameter",
50 | "datatype": "text",
51 | "defaultValue": "cfc3a225-ac57-45c9-aacd-969551f4825f",
52 | "replaces": "{{clientId}}"
53 | },
54 | "version": {
55 | "type": "parameter",
56 | "replaces": "{{version}}",
57 | "defaultValue": "v1.0"
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Ares Chen | 陈希章",
4 | "classifications": [
5 | "Common",
6 | "MVC"
7 | ],
8 | "identity": "chenxizhang.dotnetcore.msgraph.mvcapp.CSharp",
9 | "name": "Web MVC application using Microsoft Graph",
10 | "groupIdentity": "chenxizhang.dotnetcore.msgraph.mvcapp",
11 | "shortName": "graphmvcapp",
12 | "sourceName": "content",
13 | "primaryOutputs": [
14 | {
15 | "path": "content.csproj"
16 | }
17 | ],
18 | "tags": {
19 | "language": "C#",
20 | "type": "project"
21 | },
22 | "postActions": [
23 | {
24 | "description": "dotnet restore",
25 | "manualInstructions": [
26 | {
27 | "text": "Run 'dotnet restore'"
28 | }
29 | ],
30 | "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
31 | "continueOnError": true
32 | }
33 | ],
34 | "symbols": {
35 | "instance": {
36 | "type": "parameter",
37 | "datatype": "choice",
38 | "choices": [
39 | {
40 | "choice": "global"
41 | },
42 | {
43 | "choice": "gallatin"
44 | }
45 | ],
46 | "defaultValue": "global"
47 | },
48 | "clientid": {
49 | "type": "parameter",
50 | "datatype": "text",
51 | "defaultValue": "5200f0d2-0ab3-4cc4-bb13-3506a04106e0",
52 | "replaces": "{{clientId}}"
53 | },
54 | "secret": {
55 | "type": "parameter",
56 | "datatype": "text",
57 | "defaultValue": "fthpNSD50~#ppuWHNE130-+",
58 | "replaces": "{{secret}}"
59 | },
60 | "version": {
61 | "type": "parameter",
62 | "replaces": "{{version}}",
63 | "defaultValue": "v1.0"
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Ares Chen | 陈希章",
4 | "classifications": [
5 | "Common",
6 | "Web"
7 | ],
8 | "identity": "chenxizhang.dotnetcore.msgraph.webapp.CSharp",
9 | "name": "Web application using Microsoft Graph",
10 | "groupIdentity": "chenxizhang.dotnetcore.msgraph.webapp",
11 | "shortName": "graphwebapp",
12 | "sourceName": "content",
13 | "primaryOutputs": [
14 | {
15 | "path": "content.csproj"
16 | }
17 | ],
18 | "tags": {
19 | "language": "C#",
20 | "type": "project"
21 | },
22 | "postActions": [
23 | {
24 | "description": "dotnet restore",
25 | "manualInstructions": [
26 | {
27 | "text": "Run 'dotnet restore'"
28 | }
29 | ],
30 | "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
31 | "continueOnError": true
32 | }
33 | ],
34 | "symbols": {
35 | "instance": {
36 | "type": "parameter",
37 | "datatype": "choice",
38 | "choices": [
39 | {
40 | "choice": "global"
41 | },
42 | {
43 | "choice": "gallatin"
44 | }
45 | ],
46 | "defaultValue": "global"
47 | },
48 | "clientid": {
49 | "type": "parameter",
50 | "datatype": "text",
51 | "defaultValue": "5200f0d2-0ab3-4cc4-bb13-3506a04106e0",
52 | "replaces": "{{clientId}}"
53 | },
54 | "secret": {
55 | "type": "parameter",
56 | "datatype": "text",
57 | "defaultValue": "fthpNSD50~#ppuWHNE130-+",
58 | "replaces": "{{secret}}"
59 | },
60 | "version": {
61 | "type": "parameter",
62 | "replaces": "{{version}}",
63 | "defaultValue": "v1.0"
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/obj/content.csproj.nuget.g.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/obj/content.csproj.nuget.g.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/Controllers/ValuesController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Security.Claims;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Authorization;
7 | using Microsoft.AspNetCore.Mvc;
8 | using Microsoft.Extensions.Primitives;
9 | using Microsoft.IdentityModel.Clients.ActiveDirectory;
10 | using Microsoft.Graph;
11 | using System.Net.Http.Headers;
12 |
13 | namespace webapi.Controllers
14 | {
15 | [Authorize]
16 | [Route("api/[controller]")]
17 | public class ValuesController : Controller
18 | {
19 | //在这个方法中获取用户的基本信息(显示名称,UPN和部门)
20 | // GET api/values
21 | [HttpGet]
22 | public IEnumerable Get()
23 | {
24 | StringValues token;
25 | if (Request.Headers.TryGetValue("Authorization", out token))
26 | {
27 |
28 | var accesstoken = token.First().Split(' ')[1];
29 | var userAssertion = new UserAssertion(accesstoken, "urn:ietf:params:oauth:grant-type:jwt-bearer", User.Identity.Name);
30 | var clientCred = new ClientCredential(Startup.clientid, Startup.secret);
31 |
32 | var authority = Startup.authority;
33 |
34 | var ctx = new AuthenticationContext(authority);
35 | var result = ctx.AcquireTokenAsync(Startup.resource, clientCred, userAssertion).Result;
36 |
37 |
38 | var client = new GraphServiceClient(new DelegateAuthenticationProvider(async request =>
39 | {
40 | request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);
41 | await Task.FromResult(0);
42 | }))
43 | {
44 | BaseUrl = Startup.resource + "/{{version}}"
45 | };
46 |
47 | var me = client.Me.Request().GetAsync().Result;
48 | return new[] { me.DisplayName, me.UserPrincipalName, me.Department };
49 |
50 | }
51 |
52 | return new[] { "Hello,dotnet web api" };
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/lang/zh-cn/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph MVC网站应用程序模板
2 |
3 | [English](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-mvcapp/README.md) | 简体中文 | [繁體中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-mvcapp/lang/zh-tw/README.md)
4 |
5 | > 作者:陈希章 发表于 2018年4月26日
6 |
7 | ## 概述
8 |
9 | 这个项目模板可以帮助你快速建立一个MVC网站,并且以某个用户的身份调用Microsoft Graph的服务,实现了如下三个功能
10 |
11 | 1. 读取当前用户的基本信息
12 | 1. 读取当前用户的邮箱收件箱(Exchange Online)中的前十封邮件
13 | 1. 读取当前用户的个人网盘(OneDrive for Business)的根目录下面的文件列表
14 |
15 | 该模板支持国际版,也支持国内版。
16 |
17 | ## 准备
18 |
19 | 为了使用该模板,你最好能自行注册一个应用程序。如果你对这方面的概念不熟悉,请参考 [Microsoft Graph overview](https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md)的说明。
20 |
21 | 如果你是需要访问国际版Office 365,建议你直接使用AAD 2.0的注册方式,在进行注册,请参考[这篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration2.0.md)。
22 |
23 | 如果你是需要访问国内版Office 365,你目前只能使用AAD 1.0的注册方式,在进行注册,请参考[这篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md)。
24 |
25 | 这个模板范例,至少需要三个委派权限(Delegate Permission)
26 |
27 | 1. Files.Read.All
28 | 1. Mail.Read
29 | 1. User.Read
30 |
31 | 不管你采用哪种方式注册,请将Reply Url中设置为
32 |
33 | ## 安装
34 |
35 | 你通过 `dotnet new -i chenxizhang.dotnetcore.msgraph.mvcapp.CSharp` 即可安装这个项目模板。
36 |
37 | ## 使用
38 |
39 | 这个模板有几个用法,分别如下
40 |
41 | 1. 最简单的用法 `dotnet new graphmvcapp` 将创建一个模板实现,你将使用我预先创建好的一个clientid访问到Office 365国际版。
42 | 1. 通过指定`clientid`参数和`secret`参数,明确使用你的应用程序来访问Office 365, 这是我最推荐的,语法是 `dotnet new graphmvcapp --clientid 你创建的应用程序编号 --secret 你的密钥`。
43 | 1. 通过`instance`参数,指定你要访问的是国际版还是国内版。国际版是默认的,而如果要指定国内版,则需要用如下的语法 `dotnet new graphmvcapp --instance gallatin --clientid 你创建的应用程序编号 --secret 你的密钥`。
44 | 1. 通过`version`参数,指定你要访问的Graph API的版本,默认为`v1.0`,目前还支持`beta`。
45 |
46 | 另外还有两个通用参数
47 |
48 | 1. 通过指定`name` 可以改变模板生成的项目名称,以及默认的namespace名称。例如 `dotnet new graphmvcapp -n mynamespace`。
49 | 1. 通过指定`output`可以指定生成新的项目目录。例如 `dotnet new graphmvcapp -o test`。
50 |
51 | 一旦创建好项目,你可以直接通过`dotnet run`运行,或者在`Visual Studio Code`中编辑后再运行。你将在首页看到当前用户信息,邮件信息和文件列表。
52 |
53 | ## 卸载
54 |
55 | 你可以通过 `dotnet new -u chenxizhang.dotnetcore.msgraph.mvcapp.CSharp`可以卸载当前这个项目模板。
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/lang/zh-tw/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph MVC網站應用程序模板
2 |
3 | [English](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-mvcapp/README.md) | [简体中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-mvcapp/lang/zh-cn/README.md) | 繁體中文
4 |
5 | > 作者:陳希章 發表於 2018年4月26日
6 |
7 | ## 概述
8 |
9 | 這個項目模板可以幫助妳快速建立壹個MVC網站,並且以某個用戶的身份調用Microsoft Graph的服務,實現了如下三個功能
10 |
11 | 1. 讀取當前用戶的基本信息
12 | 1. 讀取當前用戶的郵箱收件箱(Exchange Online)中的前十封郵件
13 | 1. 讀取當前用戶的個人網盤(OneDrive for Business)的根目錄下面的文件列表
14 |
15 | 該模板支持國際版,也支持國內版。
16 |
17 | ## 準備
18 |
19 | 為了使用該模板,妳最好能自行註冊壹個應用程序。如果妳對這方面的概念不熟悉,請參考 [Microsoft Graph overview](https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md)的說明。
20 |
21 | 如果妳是需要訪問國際版Office 365,建議妳直接使用AAD 2.0的註冊方式,在進行註冊,請參考[這篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration2.0.md)。
22 |
23 | 如果妳是需要訪問國內版Office 365,妳目前只能使用AAD 1.0的註冊方式,在進行註冊,請參考[這篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md)。
24 |
25 | 這個模板範例,至少需要三個委派權限(Delegate Permission)
26 |
27 | 1. Files.Read.All
28 | 1. Mail.Read
29 | 1. User.Read
30 |
31 | 不管妳采用哪種方式註冊,請將Reply Url中設置為
32 |
33 | ## 安裝
34 |
35 | 妳通過 `dotnet new -i chenxizhang.dotnetcore.msgraph.mvcapp.CSharp` 即可安裝這個項目模板。
36 |
37 | ## 使用
38 |
39 | 這個模板有幾個用法,分別如下
40 |
41 | 1. 最簡單的用法 `dotnet new graphmvcapp` 將創建壹個模板實現,妳將使用我預先創建好的壹個clientid訪問到Office 365國際版。
42 | 1. 通過指定`clientid`參數和`secret`參數,明確使用妳的應用程序來訪問Office 365, 這是我最推薦的,語法是 `dotnet new graphmvcapp --clientid 妳創建的應用程序編號 --secret 妳的密鑰`。
43 | 1. 通過`instance`參數,指定妳要訪問的是國際版還是國內版。國際版是默認的,而如果要指定國內版,則需要用如下的語法 `dotnet new graphmvcapp --instance gallatin --clientid 妳創建的應用程序編號 --secret 妳的密鑰`。
44 | 1. 通過`version`參數,指定妳要訪問的Graph API的版本,默認為`v1.0`,目前還支持`beta`。
45 |
46 | 另外還有兩個通用參數
47 |
48 | 1. 通過指定`name` 可以改變模板生成的項目名稱,以及默認的namespace名稱。例如 `dotnet new graphmvcapp -n mynamespace`。
49 | 1. 通過指定`output`可以指定生成新的項目目錄。例如 `dotnet new graphmvcapp -o test`。
50 |
51 | 壹旦創建好項目,妳可以直接通過`dotnet run`運行,或者在`Visual Studio Code`中編輯後再運行。妳將在首頁看到當前用戶信息,郵件信息和文件列表。
52 |
53 | ## 卸載
54 |
55 | 妳可以通過 `dotnet new -u chenxizhang.dotnetcore.msgraph.mvcapp.CSharp`可以卸載當前這個項目模板。
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Controllers/HomeController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore.Mvc;
7 | using content.Models;
8 | using Microsoft.AspNetCore.Authorization;
9 | using Microsoft.Extensions.Configuration;
10 | using Microsoft.AspNetCore.Hosting;
11 |
12 | namespace content.Controllers
13 | {
14 | public class HomeController : Controller
15 | {
16 |
17 |
18 | private readonly IConfiguration _configuration;
19 | private readonly IHostingEnvironment _env;
20 | private readonly IGraphSDKHelper _graphSdkHelper;
21 |
22 | public HomeController(IConfiguration configuration, IHostingEnvironment hostingEnvironment, IGraphSDKHelper graphSdkHelper)
23 | {
24 | _configuration = configuration;
25 | _env = hostingEnvironment;
26 | _graphSdkHelper = graphSdkHelper;
27 | }
28 | [Authorize]
29 | public IActionResult Index()
30 | {
31 | var identifier = User.FindFirst(Startup.ObjectIdentifierType)?.Value;
32 |
33 | // Initialize the GraphServiceClient.
34 | var graphClient = _graphSdkHelper.GetServiceClient(identifier,Request.HttpContext);
35 |
36 | var me = graphClient.Me.Request().GetAsync().Result;
37 | ViewBag.me = me;
38 |
39 | var messages = graphClient.Me.Messages.Request().GetAsync().Result;
40 | ViewBag.messages = messages;
41 |
42 | var files = graphClient.Me.Drive.Root.Children.Request().GetAsync().Result;
43 | ViewBag.files = files;
44 |
45 |
46 | return View();
47 | }
48 |
49 | public IActionResult About()
50 | {
51 | ViewData["Message"] = "Your application description page.";
52 |
53 | return View();
54 | }
55 |
56 | public IActionResult Contact()
57 | {
58 | ViewData["Message"] = "Your contact page.";
59 |
60 | return View();
61 | }
62 |
63 | public IActionResult Error()
64 | {
65 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Ares Chen | 陈希章",
4 | "classifications": [
5 | "Common",
6 | "Console"
7 | ],
8 | "identity": "chenxizhang.dotnetcore.msgraph.serviceapp.CSharp",
9 | "name": "Service application using Microsoft Graph",
10 | "groupIdentity": "chenxizhang.dotnetcore.msgraph.serviceapp",
11 | "shortName": "graphserviceapp",
12 | "sourceName": "content",
13 | "primaryOutputs": [
14 | {
15 | "path": "content.csproj"
16 | }
17 | ],
18 | "tags": {
19 | "language": "C#",
20 | "type": "project"
21 | },
22 | "postActions": [
23 | {
24 | "description": "dotnet restore",
25 | "manualInstructions": [
26 | {
27 | "text": "Run 'dotnet restore'"
28 | }
29 | ],
30 | "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
31 | "continueOnError": true
32 | }
33 | ],
34 | "symbols": {
35 | "instance": {
36 | "type": "parameter",
37 | "datatype": "choice",
38 | "choices": [
39 | {
40 | "choice": "global"
41 | },
42 | {
43 | "choice": "gallatin"
44 | }
45 | ],
46 | "defaultValue": "global"
47 | },
48 | "clientid": {
49 | "type": "parameter",
50 | "datatype": "text",
51 | "defaultValue": "019dc431-2ad8-4b8e-a141-499f1ebcf737",
52 | "replaces": "{{clientId}}"
53 | },
54 | "secret": {
55 | "type": "parameter",
56 | "datatype": "text",
57 | "defaultValue": "wvfLJHK456#}oadnKTG16{{",
58 | "replaces": "{{secret}}"
59 | },
60 | "tenantid": {
61 | "type": "parameter",
62 | "datatype": "text",
63 | "defaultValue": "59723f6b-2d14-49fe-827a-8d04f9fe7a68",
64 | "replaces": "{{tenantid}}"
65 | },
66 | "version": {
67 | "type": "parameter",
68 | "replaces": "{{version}}",
69 | "defaultValue": "v1.0"
70 | }
71 | }
72 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-console/lang/zh-cn/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph 控制台应用程序模板
2 |
3 | [English](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-console/README.md) | 简体中文 | [繁體中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-console/lang/zh-tw/README.md)
4 |
5 | > 作者:陈希章 发表于 2018年4月22日
6 |
7 | ## 概述
8 |
9 | 这个项目模板可以帮助你快速建立一个控制台应用程序,并且以某个用户的身份调用Microsoft Graph的服务,实现了如下三个功能
10 |
11 | 1. 读取当前用户的基本信息
12 | 1. 读取当前用户的邮箱收件箱(Exchange Online)中的前十封邮件
13 | 1. 读取当前用户的个人网盘(OneDrive for Business)的根目录下面的文件列表
14 |
15 | 由于.NET Core是要跨平台的,所以在用户登陆这个行为上,不能采用原生的Windows操作系统中提供的弹出窗口,该模板采用了一种特殊的方式来实现。程序运行后会自动生成一个设备编号,并且给用户提示一个登陆的网页地址,用户在网页上面输入设备编号,会被引导到相应的Office 365的登陆页面,完成身份验证和授权后,控制台程序将收到通知,并且获取访问票据(Access Token),然后就可以尽情地调用Microsoft Graph了。
16 |
17 | 该模板支持国际版,也支持国内版。
18 |
19 | ## 准备
20 |
21 | 为了使用该模板,你最好能自行注册一个应用程序。如果你对这方面的概念不熟悉,请参考 [Microsoft Graph overview](https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md)的说明。
22 |
23 | 如果你是需要访问国际版Office 365,建议你直接使用AAD 2.0的注册方式,在进行注册,请参考[这篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration2.0.md)。
24 |
25 | 如果你是需要访问国内版Office 365,你目前只能使用AAD 1.0的注册方式,在进行注册,请参考[这篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md)。
26 |
27 | 这个模板范例,至少需要三个委派权限(Delegate Permission)
28 |
29 | 1. Files.Read.All
30 | 1. Mail.Read
31 | 1. User.Read
32 |
33 | ## 安装
34 |
35 | 你通过 `dotnet new -i chenxizhang.dotnetcore.msgraph.console.CSharp` 即可安装这个项目模板。
36 |
37 | ## 使用
38 |
39 | 这个模板有几个用法,分别如下
40 |
41 | 1. 最简单的用法 `dotnet new graphconsole` 将创建一个模板实现,你将使用我预先创建好的一个clientid访问到Office 365国际版。
42 | 1. 通过指定`clientid`参数,明确使用你的应用程序来访问Office 365, 这是我最推荐的,语法是 `dotnet new graphconsole --clientid 你创建的应用程序编号`。
43 | 1. 通过`instance`参数,指定你要访问的是国际版还是国内版。国际版是默认的,而如果要指定国内版,则需要用如下的语法 `dotnet new graphconsole --instance gallatin --clientid 你创建的应用程序编号`。
44 | 1. 通过`version`参数,指定你要访问的Graph API的版本,默认为`v1.0`,目前还支持`beta`。
45 |
46 | 另外还有两个通用参数
47 |
48 | 1. 通过指定`name` 可以改变模板生成的项目名称,以及默认的namespace名称。例如 `dotnet new graphconsole -n mynamespace`。
49 | 1. 通过指定`output`可以指定生成新的项目目录。例如 `dotnet new graphconsole -o test`。
50 |
51 | 一旦创建好项目,你可以直接通过`dotnet run`运行,或者在`Visual Studio Code`中编辑后再运行。
52 |
53 | ## 卸载
54 |
55 | 你可以通过 `dotnet new -u chenxizhang.dotnetcore.msgraph.console.CSharp`可以卸载当前这个项目模板。
--------------------------------------------------------------------------------
/dotnetcore-graph-console/lang/zh-tw/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph 控制臺應用程序模板
2 |
3 | [English](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-console/README.md) | [简体中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-console/lang/zh-cn/README.md) | 繁體中文
4 |
5 | > 作者:陳希章 發表於 2018年4月22日
6 |
7 | ## 概述
8 |
9 | 這個項目模板可以幫助妳快速建立壹個控制臺應用程序,並且以某個用戶的身份調用Microsoft Graph的服務,實現了如下三個功能
10 |
11 | 1. 讀取當前用戶的基本信息
12 | 1. 讀取當前用戶的郵箱收件箱(Exchange Online)中的前十封郵件
13 | 1. 讀取當前用戶的個人網盤(OneDrive for Business)的根目錄下面的文件列表
14 |
15 | 由於.NET Core是要跨平臺的,所以在用戶登陸這個行為上,不能采用原生的Windows操作系統中提供的彈出窗口,該模板采用了壹種特殊的方式來實現。程序運行後會自動生成壹個設備編號,並且給用戶提示壹個登陸的網頁地址,用戶在網頁上面輸入設備編號,會被引導到相應的Office 365的登陸頁面,完成身份驗證和授權後,控制臺程序將收到通知,並且獲取訪問票據(Access Token),然後就可以盡情地調用Microsoft Graph了。
16 |
17 | 該模板支持國際版,也支持國內版。
18 |
19 | ## 準備
20 |
21 | 為了使用該模板,妳最好能自行註冊壹個應用程序。如果妳對這方面的概念不熟悉,請參考 [Microsoft Graph overview](https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md)的說明。
22 |
23 | 如果妳是需要訪問國際版Office 365,建議妳直接使用AAD 2.0的註冊方式,在進行註冊,請參考[這篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration2.0.md)。
24 |
25 | 如果妳是需要訪問國內版Office 365,妳目前只能使用AAD 1.0的註冊方式,在進行註冊,請參考[這篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md)。
26 |
27 | 這個模板範例,至少需要三個委派權限(Delegate Permission)
28 |
29 | 1. Files.Read.All
30 | 1. Mail.Read
31 | 1. User.Read
32 |
33 | ## 安裝
34 |
35 | 妳通過 `dotnet new -i chenxizhang.dotnetcore.msgraph.console.CSharp` 即可安裝這個項目模板。
36 |
37 | ## 使用
38 |
39 | 這個模板有幾個用法,分別如下
40 |
41 | 1. 最簡單的用法 `dotnet new graphconsole` 將創建壹個模板實現,妳將使用我預先創建好的壹個clientid訪問到Office 365國際版。
42 | 1. 通過指定`clientid`參數,明確使用妳的應用程序來訪問Office 365, 這是我最推薦的,語法是 `dotnet new graphconsole --clientid 妳創建的應用程序編號`。
43 | 1. 通過`instance`參數,指定妳要訪問的是國際版還是國內版。國際版是默認的,而如果要指定國內版,則需要用如下的語法 `dotnet new graphconsole --instance gallatin --clientid 妳創建的應用程序編號`。
44 | 1. 通過`version`參數,指定妳要訪問的Graph API的版本,默認為`v1.0`,目前還支持`beta`。
45 |
46 | 另外還有兩個通用參數
47 |
48 | 1. 通過指定`name` 可以改變模板生成的項目名稱,以及默認的namespace名稱。例如 `dotnet new graphconsole -n mynamespace`。
49 | 1. 通過指定`output`可以指定生成新的項目目錄。例如 `dotnet new graphconsole -o test`。
50 |
51 | 壹旦創建好項目,妳可以直接通過`dotnet run`運行,或者在`Visual Studio Code`中編輯後再運行。
52 |
53 | ## 卸載
54 |
55 | 妳可以通過 `dotnet new -u chenxizhang.dotnetcore.msgraph.console.CSharp`可以卸載當前這個項目模板。
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/lang/zh-cn/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph Web API 模板
2 |
3 | [English](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapi/README.md) | [简体中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapi/lang/zh-cn/README.md) | [繁體中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapi/lang/zh-tw/README.md)
4 |
5 | > 作者:陈希章 发表于 2018年5月1日
6 |
7 | ## 概述
8 |
9 | 这个项目模板可以帮助你快速建立一个服务项目,并且可以接受客户端调用,通过On-Behalf-Of认证流实现以某个用户的身份调用Microsoft Graph的服务,实现了如下一个功能
10 |
11 | 1. 读取当前用户的基本信息
12 |
13 | 该模板支持国际版,也支持国内版。
14 |
15 | ## 准备
16 |
17 | 为了使用该模板,你最好能自行注册一个应用程序。如果你对这方面的概念不熟悉,请参考 [Microsoft Graph overview](https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md)的说明。
18 |
19 | 不管你是使用国际版还是国内版,你目前只能使用AAD 1.0的注册方式,在进行注册,请参考[这篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md)。
20 |
21 | 这个模板范例,至少需要一个委派权限(Delegate Permission)
22 |
23 | 1. User.Read
24 |
25 | 这个模板实现了一套完整的On-Behalf-Of认证流,即客户端应用程序先自行从Azure AD中得到访问许可,然后再调用中间层服务的时候,服务层会使用客户端的Access_Token去换取自己的Access_Token,看起来就好像客户端自己去访问一样。关于这个场景,以及如何配置On-Behalf-Of的应用程序和权限,请参考 这里的说明。你需要注册两个应用程序。
26 |
27 |
28 | ## 安装
29 |
30 | 你通过 `dotnet new -i chenxizhang.dotnetcore.msgraph.webapi.CSharp` 即可安装这个项目模板。
31 |
32 | ## 使用
33 |
34 | 这个模板有几个用法,分别如下
35 |
36 | 1. 最简单的用法 `dotnet new graphwebapi` 将创建一个模板实现,你将使用我预先创建好的一个clientid访问到Office 365国际版。
37 | 1. 通过指定`clientid`参数和`secret`参数、`tenantid`参数、`obo-console-clientid`参数,明确使用你的应用程序来访问Office 365, 这是我最推荐的,语法是 `dotnet new graphwebapi --clientid 你创建的应用程序编号 --secret 你的密钥 --tenantid 你的租户编号 --obo-console-clientid 你为客户端注册的应用程序编号`。关于如何获取`tenantid`,你也可以通过[我的这篇文章](http://www.cnblogs.com/chenxizhang/p/7904293.html)所介绍的PowerShell方法获取。
38 | 1. 通过`instance`参数,指定你要访问的是国际版还是国内版。国际版是默认的,而如果要指定国内版,则需要用如下的语法 `dotnet new graphwebapi --instance gallatin --clientid 你创建的应用程序编号 --secret 你的密钥`。
39 | 1. 通过`version`参数,指定你要访问的Graph API的版本,默认为`v1.0`,目前还支持`beta`。
40 |
41 | 另外还有两个通用参数
42 |
43 | 1. 通过指定`name` 可以改变模板生成的项目名称,以及默认的namespace名称。例如 `dotnet new graphwebapi -n mynamespace`。
44 | 1. 通过指定`output`可以指定生成新的项目目录。例如 `dotnet new graphwebapi -o test`。
45 |
46 | 一旦创建好项目,你可以直接通过`dotnet run`运行,或者在`Visual Studio Code`中编辑后再运行。
47 |
48 | 1. 读取当前用户的基本信息
49 |
50 | ## 卸载
51 |
52 | 你可以通过 `dotnet new -u chenxizhang.dotnetcore.msgraph.webapi.CSharp`可以卸载当前这个项目模板。
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/lang/zh-tw/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph Web API 模板
2 |
3 | [English](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapi/README.md) | [简体中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapi/lang/zh-cn/README.md) | [繁體中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapi/lang/zh-tw/README.md)
4 |
5 | > 作者:陳希章 發表於 2018年5月1日
6 |
7 | ## 概述
8 |
9 | 這個項目模板可以幫助妳快速建立壹個服務項目,並且可以接受客戶端調用,通過On-Behalf-Of認證流實現以某個用戶的身份調用Microsoft Graph的服務,實現了如下壹個功能
10 |
11 | 1. 讀取當前用戶的基本信息
12 |
13 | 該模板支持國際版,也支持國內版。
14 |
15 | ## 準備
16 |
17 | 為了使用該模板,妳最好能自行註冊壹個應用程序。如果妳對這方面的概念不熟悉,請參考 [Microsoft Graph overview](https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md)的說明。
18 |
19 | 不管妳是使用國際版還是國內版,妳目前只能使用AAD 1.0的註冊方式,在進行註冊,請參考[這篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md)。
20 |
21 | 這個模板範例,至少需要壹個委派權限(Delegate Permission)
22 |
23 | 1. User.Read
24 |
25 | 這個模板實現了壹套完整的On-Behalf-Of認證流,即客戶端應用程序先自行從Azure AD中得到訪問許可,然後再調用中間層服務的時候,服務層會使用客戶端的Access_Token去換取自己的Access_Token,看起來就好像客戶端自己去訪問壹樣。關於這個場景,以及如何配置On-Behalf-Of的應用程序和權限,請參考 這裏的說明。妳需要註冊兩個應用程序。
26 |
27 |
28 | ## 安裝
29 |
30 | 妳通過 `dotnet new -i chenxizhang.dotnetcore.msgraph.webapi.CSharp` 即可安裝這個項目模板。
31 |
32 | ## 使用
33 |
34 | 這個模板有幾個用法,分別如下
35 |
36 | 1. 最簡單的用法 `dotnet new graphwebapi` 將創建壹個模板實現,妳將使用我預先創建好的壹個clientid訪問到Office 365國際版。
37 | 1. 通過指定`clientid`參數和`secret`參數、`tenantid`參數、`obo-console-clientid`參數,明確使用妳的應用程序來訪問Office 365, 這是我最推薦的,語法是 `dotnet new graphwebapi --clientid 妳創建的應用程序編號 --secret 妳的密鑰 --tenantid 妳的租戶編號 --obo-console-clientid 妳為客戶端註冊的應用程序編號`。關於如何獲取`tenantid`,妳也可以通過[我的這篇文章](http://www.cnblogs.com/chenxizhang/p/7904293.html)所介紹的PowerShell方法獲取。
38 | 1. 通過`instance`參數,指定妳要訪問的是國際版還是國內版。國際版是默認的,而如果要指定國內版,則需要用如下的語法 `dotnet new graphwebapi --instance gallatin --clientid 妳創建的應用程序編號 --secret 妳的密鑰`。
39 | 1. 通過`version`參數,指定妳要訪問的Graph API的版本,默認為`v1.0`,目前還支持`beta`。
40 |
41 | 另外還有兩個通用參數
42 |
43 | 1. 通過指定`name` 可以改變模板生成的項目名稱,以及默認的namespace名稱。例如 `dotnet new graphwebapi -n mynamespace`。
44 | 1. 通過指定`output`可以指定生成新的項目目錄。例如 `dotnet new graphwebapi -o test`。
45 |
46 | 壹旦創建好項目,妳可以直接通過`dotnet run`運行,或者在`Visual Studio Code`中編輯後再運行。
47 |
48 | 1. 讀取當前用戶的基本信息
49 |
50 | ## 卸載
51 |
52 | 妳可以通過 `dotnet new -u chenxizhang.dotnetcore.msgraph.webapi.CSharp`可以卸載當前這個項目模板。
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/lang/zh-cn/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph 网站应用程序模板
2 |
3 | [English](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapp/README.md) | 简体中文 | [繁體中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapp/lang/zh-tw/README.md)
4 |
5 | > 作者:陈希章 发表于 2018年4月28日
6 |
7 | ## 概述
8 |
9 | 这个项目模板可以帮助你快速建立一个网站,并且以某个用户的身份调用Microsoft Graph的服务,实现了如下三个功能
10 |
11 | 1. 读取当前用户的基本信息
12 | 1. 读取当前用户的邮箱收件箱(Exchange Online)中的前十封邮件
13 | 1. 读取当前用户的个人网盘(OneDrive for Business)的根目录下面的文件列表
14 |
15 | 该模板支持国际版,也支持国内版。
16 |
17 | ## 准备
18 |
19 | 为了使用该模板,你最好能自行注册一个应用程序。如果你对这方面的概念不熟悉,请参考 [Microsoft Graph overview](https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md)的说明。
20 |
21 | 如果你是需要访问国际版Office 365,建议你直接使用AAD 2.0的注册方式,在进行注册,请参考[这篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration2.0.md)。
22 |
23 | 如果你是需要访问国内版Office 365,你目前只能使用AAD 1.0的注册方式,在进行注册,请参考[这篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md)。
24 |
25 | 这个模板范例,至少需要三个委派权限(Delegate Permission)
26 |
27 | 1. Files.Read.All
28 | 1. Mail.Read
29 | 1. User.Read
30 |
31 | 不管你采用哪种方式注册,请将Reply Url中设置为
32 |
33 | ## 安装
34 |
35 | 你通过 `dotnet new -i chenxizhang.dotnetcore.msgraph.webapp.CSharp` 即可安装这个项目模板。
36 |
37 | ## 使用
38 |
39 | 这个模板有几个用法,分别如下
40 |
41 | 1. 最简单的用法 `dotnet new graphwebapp` 将创建一个模板实现,你将使用我预先创建好的一个clientid访问到Office 365国际版。
42 | 1. 通过指定`clientid`参数和`secret`参数,明确使用你的应用程序来访问Office 365, 这是我最推荐的,语法是 `dotnet new graphwebapp --clientid 你创建的应用程序编号 --secret 你的密钥`。
43 | 1. 通过`instance`参数,指定你要访问的是国际版还是国内版。国际版是默认的,而如果要指定国内版,则需要用如下的语法 `dotnet new graphwebapp --instance gallatin --clientid 你创建的应用程序编号 --secret 你的密钥`。
44 | 1. 通过`version`参数,指定你要访问的Graph API的版本,默认为`v1.0`,目前还支持`beta`。
45 |
46 | 另外还有两个通用参数
47 |
48 | 1. 通过指定`name` 可以改变模板生成的项目名称,以及默认的namespace名称。例如 `dotnet new graphwebapp -n mynamespace`。
49 | 1. 通过指定`output`可以指定生成新的项目目录。例如 `dotnet new graphwebapp -o test`。
50 |
51 | 一旦创建好项目,你可以直接通过`dotnet run`运行,或者在`Visual Studio Code`中编辑后再运行。你可以通过如下的地址访问三个默认的功能:
52 |
53 | 1. 读取当前用户的基本信息()
54 | 1. 读取当前用户的邮箱收件箱(Exchange Online)中的前十封邮件()
55 | 1. 读取当前用户的个人网盘(OneDrive for Business)的根目录下面的文件列表()
56 |
57 | ## 卸载
58 |
59 | 你可以通过 `dotnet new -u chenxizhang.dotnetcore.msgraph.webapp.CSharp`可以卸载当前这个项目模板。
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/lang/zh-tw/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph 網站應用程序模板
2 |
3 | [English](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapp/README.md) | [简体中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapp/lang/zh-cn/README.md) | 繁體中文
4 |
5 | > 作者:陳希章 發表於 2018年4月28日
6 |
7 | ## 概述
8 |
9 | 這個項目模板可以幫助妳快速建立壹個網站,並且以某個用戶的身份調用Microsoft Graph的服務,實現了如下三個功能
10 |
11 | 1. 讀取當前用戶的基本信息
12 | 1. 讀取當前用戶的郵箱收件箱(Exchange Online)中的前十封郵件
13 | 1. 讀取當前用戶的個人網盤(OneDrive for Business)的根目錄下面的文件列表
14 |
15 | 該模板支持國際版,也支持國內版。
16 |
17 | ## 準備
18 |
19 | 為了使用該模板,妳最好能自行註冊壹個應用程序。如果妳對這方面的概念不熟悉,請參考 [Microsoft Graph overview](https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md)的說明。
20 |
21 | 如果妳是需要訪問國際版Office 365,建議妳直接使用AAD 2.0的註冊方式,在進行註冊,請參考[這篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration2.0.md)。
22 |
23 | 如果妳是需要訪問國內版Office 365,妳目前只能使用AAD 1.0的註冊方式,在進行註冊,請參考[這篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md)。
24 |
25 | 這個模板範例,至少需要三個委派權限(Delegate Permission)
26 |
27 | 1. Files.Read.All
28 | 1. Mail.Read
29 | 1. User.Read
30 |
31 | 不管妳采用哪種方式註冊,請將Reply Url中設置為
32 |
33 | ## 安裝
34 |
35 | 妳通過 `dotnet new -i chenxizhang.dotnetcore.msgraph.webapp.CSharp` 即可安裝這個項目模板。
36 |
37 | ## 使用
38 |
39 | 這個模板有幾個用法,分別如下
40 |
41 | 1. 最簡單的用法 `dotnet new graphwebapp` 將創建壹個模板實現,妳將使用我預先創建好的壹個clientid訪問到Office 365國際版。
42 | 1. 通過指定`clientid`參數和`secret`參數,明確使用妳的應用程序來訪問Office 365, 這是我最推薦的,語法是 `dotnet new graphwebapp --clientid 妳創建的應用程序編號 --secret 妳的密鑰`。
43 | 1. 通過`instance`參數,指定妳要訪問的是國際版還是國內版。國際版是默認的,而如果要指定國內版,則需要用如下的語法 `dotnet new graphwebapp --instance gallatin --clientid 妳創建的應用程序編號 --secret 妳的密鑰`。
44 | 1. 通過`version`參數,指定妳要訪問的Graph API的版本,默認為`v1.0`,目前還支持`beta`。
45 |
46 | 另外還有兩個通用參數
47 |
48 | 1. 通過指定`name` 可以改變模板生成的項目名稱,以及默認的namespace名稱。例如 `dotnet new graphwebapp -n mynamespace`。
49 | 1. 通過指定`output`可以指定生成新的項目目錄。例如 `dotnet new graphwebapp -o test`。
50 |
51 | 壹旦創建好項目,妳可以直接通過`dotnet run`運行,或者在`Visual Studio Code`中編輯後再運行。妳可以通過如下的地址訪問三個默認的功能:
52 |
53 | 1. 讀取當前用戶的基本信息()
54 | 1. 讀取當前用戶的郵箱收件箱(Exchange Online)中的前十封郵件()
55 | 1. 讀取當前用戶的個人網盤(OneDrive for Business)的根目錄下面的文件列表()
56 |
57 | ## 卸載
58 |
59 | 妳可以通過 `dotnet new -u chenxizhang.dotnetcore.msgraph.webapp.CSharp`可以卸載當前這個項目模板。
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Ares Chen | 陈希章",
4 | "classifications": [
5 | "Common",
6 | "Web"
7 | ],
8 | "identity": "chenxizhang.dotnetcore.msgraph.webapi.CSharp",
9 | "name": "Web api application using Microsoft Graph",
10 | "groupIdentity": "chenxizhang.dotnetcore.msgraph.webapi",
11 | "shortName": "graphwebapi",
12 | "sourceName": "content",
13 | "tags": {
14 | "language": "C#",
15 | "type": "project"
16 | },
17 | "primaryOutputs": [
18 | {
19 | "path": "content.sln"
20 | }
21 | ],
22 | "postActions": [
23 | {
24 | "description": "dotnet restore",
25 | "manualInstructions": [
26 | {
27 | "text": "Run 'dotnet restore'"
28 | }
29 | ],
30 | "actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
31 | "continueOnError": true
32 | }
33 | ],
34 | "symbols": {
35 | "instance": {
36 | "type": "parameter",
37 | "datatype": "choice",
38 | "choices": [
39 | {
40 | "choice": "global"
41 | },
42 | {
43 | "choice": "gallatin"
44 | }
45 | ],
46 | "defaultValue": "global"
47 | },
48 | "clientid": {
49 | "type": "parameter",
50 | "datatype": "text",
51 | "defaultValue": "653052ff-3dc1-4de3-9bee-ccc268a7cbfa",
52 | "replaces": "{{clientId}}"
53 | },
54 | "secret": {
55 | "type": "parameter",
56 | "datatype": "text",
57 | "defaultValue": "fS1b8Ba3/0L37d8veyNmifFN1MoW+yXzBvfFBW1QXj4=",
58 | "replaces": "{{secret}}"
59 | },
60 | "tenantid": {
61 | "type": "parameter",
62 | "datatype": "text",
63 | "defaultValue": "59723f6b-2d14-49fe-827a-8d04f9fe7a68",
64 | "replaces": "{{tenantid}}"
65 | },
66 | "obo-console-clientid": {
67 | "type": "parameter",
68 | "datatype": "text",
69 | "defaultValue": "27e28dab-6cd7-4ae9-8d61-f8fc376df55f",
70 | "replaces": "{{obo-console-clientid}}"
71 | },
72 | "version": {
73 | "type": "parameter",
74 | "replaces": "{{version}}",
75 | "defaultValue": "v1.0"
76 | }
77 | }
78 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/content/SessionTokenCache.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using Microsoft.Extensions.Caching.Memory;
3 | using Microsoft.IdentityModel.Clients.ActiveDirectory;
4 |
5 | public class SessionTokenCache
6 | {
7 | private static readonly object FileLock = new object();
8 | private readonly string _cacheId;
9 | private readonly IMemoryCache _memoryCache;
10 | private TokenCache _cache = new TokenCache();
11 |
12 | public SessionTokenCache(string userId, IMemoryCache memoryCache)
13 | {
14 | // not object, we want the SUB
15 | _cacheId = userId + "_TokenCache";
16 | _memoryCache = memoryCache;
17 |
18 | Load();
19 | }
20 |
21 | public TokenCache GetCacheInstance()
22 | {
23 | _cache.BeforeAccess = BeforeAccessNotification;
24 | _cache.AfterAccess = AfterAccessNotification;
25 |
26 | Load();
27 |
28 | return _cache;
29 | }
30 |
31 | public void SaveUserStateValue(string state)
32 | {
33 | lock (FileLock)
34 | {
35 | _memoryCache.Set(_cacheId + "_state", Encoding.ASCII.GetBytes(state));
36 | }
37 | }
38 |
39 | public string ReadUserStateValue()
40 | {
41 | string state;
42 | lock (FileLock)
43 | {
44 | state = Encoding.ASCII.GetString(_memoryCache.Get(_cacheId + "_state") as byte[]);
45 | }
46 |
47 | return state;
48 | }
49 |
50 | public void Load()
51 | {
52 | lock (FileLock)
53 | {
54 | _cache.Deserialize(_memoryCache.Get(_cacheId) as byte[]);
55 | }
56 | }
57 |
58 | public void Persist()
59 | {
60 | lock (FileLock)
61 | {
62 | // reflect changes in the persistent store
63 | _memoryCache.Set(_cacheId, _cache.Serialize());
64 | // once the write operation took place, restore the HasStateChanged bit to false
65 | _cache.HasStateChanged = false;
66 | }
67 | }
68 |
69 | // Empties the persistent store.
70 | public void Clear()
71 | {
72 | _cache = null;
73 | lock (FileLock)
74 | {
75 | _memoryCache.Remove(_cacheId);
76 | }
77 | }
78 |
79 | // Triggered right before MSAL needs to access the cache.
80 | // Reload the cache from the persistent store in case it changed since the last access.
81 | private void BeforeAccessNotification(TokenCacheNotificationArgs args)
82 | {
83 | Load();
84 | }
85 |
86 | // Triggered right after MSAL accessed the cache.
87 | private void AfterAccessNotification(TokenCacheNotificationArgs args)
88 | {
89 | // if the access operation resulted in a cache update
90 | if (_cache.HasStateChanged)
91 | {
92 | Persist();
93 | }
94 | }
95 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Helpers/SessionTokenCache.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 | using Microsoft.Extensions.Caching.Memory;
3 | using Microsoft.IdentityModel.Clients.ActiveDirectory;
4 |
5 | public class SessionTokenCache
6 | {
7 | private static readonly object FileLock = new object();
8 | private readonly string _cacheId;
9 | private readonly IMemoryCache _memoryCache;
10 | private TokenCache _cache = new TokenCache();
11 |
12 | public SessionTokenCache(string userId, IMemoryCache memoryCache)
13 | {
14 | // not object, we want the SUB
15 | _cacheId = userId + "_TokenCache";
16 | _memoryCache = memoryCache;
17 |
18 | Load();
19 | }
20 |
21 | public TokenCache GetCacheInstance()
22 | {
23 | _cache.BeforeAccess = BeforeAccessNotification;
24 | _cache.AfterAccess = AfterAccessNotification;
25 |
26 | Load();
27 |
28 | return _cache;
29 | }
30 |
31 | public void SaveUserStateValue(string state)
32 | {
33 | lock (FileLock)
34 | {
35 | _memoryCache.Set(_cacheId + "_state", Encoding.ASCII.GetBytes(state));
36 | }
37 | }
38 |
39 | public string ReadUserStateValue()
40 | {
41 | string state;
42 | lock (FileLock)
43 | {
44 | state = Encoding.ASCII.GetString(_memoryCache.Get(_cacheId + "_state") as byte[]);
45 | }
46 |
47 | return state;
48 | }
49 |
50 | public void Load()
51 | {
52 | lock (FileLock)
53 | {
54 | _cache.Deserialize(_memoryCache.Get(_cacheId) as byte[]);
55 | }
56 | }
57 |
58 | public void Persist()
59 | {
60 | lock (FileLock)
61 | {
62 | // reflect changes in the persistent store
63 | _memoryCache.Set(_cacheId, _cache.Serialize());
64 | // once the write operation took place, restore the HasStateChanged bit to false
65 | _cache.HasStateChanged = false;
66 | }
67 | }
68 |
69 | // Empties the persistent store.
70 | public void Clear()
71 | {
72 | _cache = null;
73 | lock (FileLock)
74 | {
75 | _memoryCache.Remove(_cacheId);
76 | }
77 | }
78 |
79 | // Triggered right before MSAL needs to access the cache.
80 | // Reload the cache from the persistent store in case it changed since the last access.
81 | private void BeforeAccessNotification(TokenCacheNotificationArgs args)
82 | {
83 | Load();
84 | }
85 |
86 | // Triggered right after MSAL accessed the cache.
87 | private void AfterAccessNotification(TokenCacheNotificationArgs args)
88 | {
89 | // if the access operation resulted in a cache update
90 | if (_cache.HasStateChanged)
91 | {
92 | Persist();
93 | }
94 | }
95 | }
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/lang/zh-cn/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph 服务应用程序模板
2 |
3 | [English](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-serviceapp/README.md) | 简体中文 | [繁體中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-serviceapp/lang/zh-tw/README.md)
4 |
5 | > 作者:陈希章 发表于 2018年4月22日
6 |
7 | ## 概述
8 |
9 | 服务应用程序指的是不需要用户交互的一类应用程序,他们很可能是通过定时器在后台运行。由于这种特性,它们在访问Microsoft Graph时往往不是以某个特定的用户身份,而是用一个固定的身份来完成。在这个项目模板中,我们实现的是Oauth 2.0中标准的Client Credential 这种认证流程,即应用程序使用自己的应用程序编号(`clientid`),和一个密钥(`secret`)来表明自己的身份,而它获得的权限,在得到Office 365 管理员确认后,可以访问任何用户的数据。
10 |
11 | 该模板实现了五个基本功能
12 |
13 | 1. 读取所有用户信息
14 | 1. 读取某个用户的收件箱邮件列表
15 | 1. 读取某个用户的个人网盘根目录的文件列表
16 | 1. 代表某个用户发送邮件
17 | 1. 给某个用户的个人网盘上传一个文本文件
18 |
19 | ## 准备
20 |
21 | 为了使用该模板,你最好能自行注册一个应用程序。如果你对这方面的概念不熟悉,请参考 [Microsoft Graph overview](https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md)的说明。
22 |
23 | 如果你是需要访问国际版Office 365,建议你直接使用AAD 2.0的注册方式,在进行注册,请参考[这篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration2.0.md)。
24 |
25 | 如果你是需要访问国内版Office 365,你目前只能使用AAD 1.0的注册方式,在进行注册,请参考[这篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md)。
26 |
27 | 请在注册应用程序后,生成一个新的密钥(secret),并且复制保存起来。
28 |
29 | 这个模板范例,至少需要三个应用权限(Application Permission)
30 |
31 | 1. Files.Read.All(Admin)
32 | 1. Mail.Read(Admin)
33 | 1. User.Read.All(Admin)
34 | 1. Mail.Send(Admin)
35 | 1. File.ReadWrite.All(Admin)
36 |
37 | 请注意,这一类应用权限,需要得到Office 365管理的确认(Admin consent),项目生成后,还会有这方面的操作提示。
38 |
39 | ## 安装
40 |
41 | 你通过 `dotnet new -i chenxizhang.dotnetcore.msgraph.serviceapp.CSharp` 即可安装这个项目模板。
42 |
43 | ## 使用
44 |
45 | 这个项目模板定义了五个参数,分别如下
46 |
47 | 1. `instance`,用来定义目标Office 365环境的版本,`global`代表国际版(默认),`gallatin`代表国内版。
48 | 1. `clientid`,注册应用程序时获得的应用程序编号。
49 | 1. `secret`,注册应用程序时生成的密钥。
50 | 1. `tenantid`,指定你要最终访问的租户id。不同于委派权限,应用程序权限都必须要明确地限定到具体的租户,而不是多租户的。这个tenantid有几种方式获取,一种是你在做Admin consent的时候,在返回结果的地址栏中有这个信息。你也可以通过[我的这篇文章](http://www.cnblogs.com/chenxizhang/p/7904293.html)所介绍的PowerShell方法获取。
51 | 1. `version`,指定你要访问的Graph API的版本,默认为`v1.0`,目前还支持`beta`。
52 |
53 | 如果你还不太清楚怎么注册应用程序,以及如何做Admin consent,你可以直接运行最基本的一个命令`dotnet new graphserviceapp`,使用我配置好的一个环境体验一下这几个功能。
54 | > 我的这个测试环境经常会修改,而且可能会过期,所以可能你在用的时候会遇到无法正常工作的情况。
55 |
56 | 该模板的常规使用方法是至少指定前四个参数,如 `dotnet new graphserviceapp --instance gallatin --clientid 你的应用程序编号 --secret 你的密钥 --tenantid 你的租户编号`。
57 |
58 | 另外还有两个通用参数
59 |
60 | 1. 通过指定`name` 可以改变模板生成的项目名称,以及默认的namespace名称。例如 `dotnet new graphserviceapp -n myserviceapp`。
61 | 1. 通过指定`output`可以指定生成新的项目目录。例如 `dotnet new graphserviceapp -o testapp`。
62 |
63 | 另外,请注意,项目生成后你不能直接就`dotnet run`进行运行,而是至少修改两行代码(第72,73行),设置你要访问的用户upn和邮件收件人信息。
64 |
65 | ## 卸载
66 |
67 | 你可以通过 `dotnet new -u chenxizhang.dotnetcore.msgraph.serviceapp.CSharp`可以卸载当前这个项目模板。
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/lang/zh-tw/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph 服務應用程序模板
2 |
3 | [English](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-serviceapp/README.md) | [简体中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-serviceapp/lang/zh-cn/README.md) | 繁體中文
4 |
5 | > 作者:陳希章 發表於 2018年4月22日
6 |
7 | ## 概述
8 |
9 | 服務應用程序指的是不需要用戶交互的壹類應用程序,他們很可能是通過定時器在後臺運行。由於這種特性,它們在訪問Microsoft Graph時往往不是以某個特定的用戶身份,而是用壹個固定的身份來完成。在這個項目模板中,我們實現的是Oauth 2.0中標準的Client Credential 這種認證流程,即應用程序使用自己的應用程序編號(`clientid`),和壹個密鑰(`secret`)來表明自己的身份,而它獲得的權限,在得到Office 365 管理員確認後,可以訪問任何用戶的數據。
10 |
11 | 該模板實現了五個基本功能
12 |
13 | 1. 讀取所有用戶信息
14 | 1. 讀取某個用戶的收件箱郵件列表
15 | 1. 讀取某個用戶的個人網盤根目錄的文件列表
16 | 1. 代表某個用戶發送郵件
17 | 1. 給某個用戶的個人網盤上傳壹個文本文件
18 |
19 | ## 準備
20 |
21 | 為了使用該模板,妳最好能自行註冊壹個應用程序。如果妳對這方面的概念不熟悉,請參考 [Microsoft Graph overview](https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md)的說明。
22 |
23 | 如果妳是需要訪問國際版Office 365,建議妳直接使用AAD 2.0的註冊方式,在進行註冊,請參考[這篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration2.0.md)。
24 |
25 | 如果妳是需要訪問國內版Office 365,妳目前只能使用AAD 1.0的註冊方式,在進行註冊,請參考[這篇文章](https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md)。
26 |
27 | 請在註冊應用程序後,生成壹個新的密鑰(secret),並且復制保存起來。
28 |
29 | 這個模板範例,至少需要三個應用權限(Application Permission)
30 |
31 | 1. Files.Read.All(Admin)
32 | 1. Mail.Read(Admin)
33 | 1. User.Read.All(Admin)
34 | 1. Mail.Send(Admin)
35 | 1. File.ReadWrite.All(Admin)
36 |
37 | 請註意,這壹類應用權限,需要得到Office 365管理的確認(Admin consent),項目生成後,還會有這方面的操作提示。
38 |
39 | ## 安裝
40 |
41 | 妳通過 `dotnet new -i chenxizhang.dotnetcore.msgraph.serviceapp.CSharp` 即可安裝這個項目模板。
42 |
43 | ## 使用
44 |
45 | 這個項目模板定義了五個參數,分別如下
46 |
47 | 1. `instance`,用來定義目標Office 365環境的版本,`global`代表國際版(默認),`gallatin`代表國內版。
48 | 1. `clientid`,註冊應用程序時獲得的應用程序編號。
49 | 1. `secret`,註冊應用程序時生成的密鑰。
50 | 1. `tenantid`,指定妳要最終訪問的租戶id。不同於委派權限,應用程序權限都必須要明確地限定到具體的租戶,而不是多租戶的。這個tenantid有幾種方式獲取,壹種是妳在做Admin consent的時候,在返回結果的地址欄中有這個信息。妳也可以通過[我的這篇文章](http://www.cnblogs.com/chenxizhang/p/7904293.html)所介紹的PowerShell方法獲取。
51 | 1. `version`,指定妳要訪問的Graph API的版本,默認為`v1.0`,目前還支持`beta`。
52 |
53 | 如果妳還不太清楚怎麽註冊應用程序,以及如何做Admin consent,妳可以直接運行最基本的壹個命令`dotnet new graphserviceapp`,使用我配置好的壹個環境體驗壹下這幾個功能。
54 | > 我的這個測試環境經常會修改,而且可能會過期,所以可能妳在用的時候會遇到無法正常工作的情況。
55 |
56 | 該模板的常規使用方法是至少指定前四個參數,如 `dotnet new graphserviceapp --instance gallatin --clientid 妳的應用程序編號 --secret 妳的密鑰 --tenantid 妳的租戶編號`。
57 |
58 | 另外還有兩個通用參數
59 |
60 | 1. 通過指定`name` 可以改變模板生成的項目名稱,以及默認的namespace名稱。例如 `dotnet new graphserviceapp -n myserviceapp`。
61 | 1. 通過指定`output`可以指定生成新的項目目錄。例如 `dotnet new graphserviceapp -o testapp`。
62 |
63 | 另外,請註意,項目生成後妳不能直接就`dotnet run`進行運行,而是至少修改兩行代碼(第72,73行),設置妳要訪問的用戶upn和郵件收件人信息。
64 |
65 | ## 卸載
66 |
67 | 妳可以通過 `dotnet new -u chenxizhang.dotnetcore.msgraph.serviceapp.CSharp`可以卸載當前這個項目模板。
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/content.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26124.0
5 | MinimumVisualStudioVersion = 15.0.26124.0
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "client", "client\client.csproj", "{E8C04AB5-BE0E-491D-880F-AC376E3BE234}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "webapi", "webapi\webapi.csproj", "{AE72069F-0E41-43BE-856C-945C33013721}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Debug|x64 = Debug|x64
14 | Debug|x86 = Debug|x86
15 | Release|Any CPU = Release|Any CPU
16 | Release|x64 = Release|x64
17 | Release|x86 = Release|x86
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {E8C04AB5-BE0E-491D-880F-AC376E3BE234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {E8C04AB5-BE0E-491D-880F-AC376E3BE234}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {E8C04AB5-BE0E-491D-880F-AC376E3BE234}.Debug|x64.ActiveCfg = Debug|Any CPU
26 | {E8C04AB5-BE0E-491D-880F-AC376E3BE234}.Debug|x64.Build.0 = Debug|Any CPU
27 | {E8C04AB5-BE0E-491D-880F-AC376E3BE234}.Debug|x86.ActiveCfg = Debug|Any CPU
28 | {E8C04AB5-BE0E-491D-880F-AC376E3BE234}.Debug|x86.Build.0 = Debug|Any CPU
29 | {E8C04AB5-BE0E-491D-880F-AC376E3BE234}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {E8C04AB5-BE0E-491D-880F-AC376E3BE234}.Release|Any CPU.Build.0 = Release|Any CPU
31 | {E8C04AB5-BE0E-491D-880F-AC376E3BE234}.Release|x64.ActiveCfg = Release|Any CPU
32 | {E8C04AB5-BE0E-491D-880F-AC376E3BE234}.Release|x64.Build.0 = Release|Any CPU
33 | {E8C04AB5-BE0E-491D-880F-AC376E3BE234}.Release|x86.ActiveCfg = Release|Any CPU
34 | {E8C04AB5-BE0E-491D-880F-AC376E3BE234}.Release|x86.Build.0 = Release|Any CPU
35 | {AE72069F-0E41-43BE-856C-945C33013721}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36 | {AE72069F-0E41-43BE-856C-945C33013721}.Debug|Any CPU.Build.0 = Debug|Any CPU
37 | {AE72069F-0E41-43BE-856C-945C33013721}.Debug|x64.ActiveCfg = Debug|Any CPU
38 | {AE72069F-0E41-43BE-856C-945C33013721}.Debug|x64.Build.0 = Debug|Any CPU
39 | {AE72069F-0E41-43BE-856C-945C33013721}.Debug|x86.ActiveCfg = Debug|Any CPU
40 | {AE72069F-0E41-43BE-856C-945C33013721}.Debug|x86.Build.0 = Debug|Any CPU
41 | {AE72069F-0E41-43BE-856C-945C33013721}.Release|Any CPU.ActiveCfg = Release|Any CPU
42 | {AE72069F-0E41-43BE-856C-945C33013721}.Release|Any CPU.Build.0 = Release|Any CPU
43 | {AE72069F-0E41-43BE-856C-945C33013721}.Release|x64.ActiveCfg = Release|Any CPU
44 | {AE72069F-0E41-43BE-856C-945C33013721}.Release|x64.Build.0 = Release|Any CPU
45 | {AE72069F-0E41-43BE-856C-945C33013721}.Release|x86.ActiveCfg = Release|Any CPU
46 | {AE72069F-0E41-43BE-856C-945C33013721}.Release|x86.Build.0 = Release|Any CPU
47 | EndGlobalSection
48 | EndGlobal
49 |
--------------------------------------------------------------------------------
/dotnetcore-graph-console/content/Program.cs:
--------------------------------------------------------------------------------
1 | /*
2 | 作者:陈希章 Ares Chen
3 | 时间:2018年4月21日
4 | 说明:
5 | 这是一个可以快速通过Microsoft Graph访问到Office 365资源的控制台应用程序模板。
6 | 它使用基于设备的身份验证方式,并且同时支持国际版和国内版。
7 |
8 | 关于此模板的使用以及问题反馈,请访问 https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-console
9 | Office 365开发入门指南,请参考 https://github.com/chenxizhang/office365dev
10 | 更多模板请参考 https://github.com/chenxizhang/dotnetcore-office365dev-templates
11 | */
12 | using System;
13 | using System.Net.Http.Headers;
14 | using System.Threading.Tasks;
15 | using Microsoft.Graph;
16 | using Microsoft.IdentityModel.Clients.ActiveDirectory;
17 |
18 | namespace content
19 | {
20 | class Program
21 | {
22 | static void Main(string[] args)
23 | {
24 | #region parameters
25 | string authority,resource,deviceloginaddr;
26 | //#if(instance=="gallatin")
27 | authority ="https://login.chinacloudapi.cn/common";
28 | resource ="https://microsoftgraph.chinacloudapi.cn";
29 | deviceloginaddr="https://aka.ms/gallatindevicelogin";
30 |
31 | //#else
32 | authority ="https://login.microsoftonline.com/common";
33 | resource="https://graph.microsoft.com";
34 | deviceloginaddr="https://aka.ms/devicelogin";
35 |
36 | //#endif
37 | #endregion
38 |
39 |
40 |
41 | var token = "";
42 |
43 | var client = new GraphServiceClient(new DelegateAuthenticationProvider((request) =>
44 | {
45 | if (string.IsNullOrEmpty(token))
46 | {
47 | var ctx = new AuthenticationContext(authority: authority);
48 | var deviceCode = ctx.AcquireDeviceCodeAsync(resource, "{{clientId}}").Result;
49 | Console.WriteLine($"请打开浏览器,访问 {deviceloginaddr} ,并以 {deviceCode.UserCode} 登陆");
50 | token = ctx.AcquireTokenByDeviceCodeAsync(deviceCode).Result.AccessToken;
51 | }
52 |
53 | request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
54 | return Task.FromResult(0);
55 | }))
56 | {
57 | BaseUrl = $"{resource}/{{version}}"
58 | };
59 |
60 | var user = client.Me.Request().GetAsync().Result;
61 | Console.WriteLine($"当前登录用户为:{user.DisplayName}\r\n");
62 |
63 | var messages = client.Me.Messages.Request().GetAsync().Result;
64 | Console.WriteLine($"当前用户的收件箱最近十封邮件如下:");
65 | foreach (var item in messages)
66 | {
67 | Console.WriteLine($"\t{item.Subject}");
68 | }
69 |
70 | var files = client.Me.Drive.Root.Children.Request().GetAsync().Result;
71 | Console.WriteLine($"\r\n当前用户的个人网盘的文件信息如下:");
72 | foreach (var item in files)
73 | {
74 | Console.WriteLine($"\t{item.Name}");
75 | }
76 |
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/Startup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Builder;
6 | using Microsoft.AspNetCore.Hosting;
7 | using Microsoft.Extensions.Configuration;
8 | using Microsoft.Extensions.DependencyInjection;
9 | using Microsoft.Extensions.Logging;
10 | using Microsoft.Extensions.Options;
11 | using Microsoft.AspNetCore.Authentication;
12 | using Microsoft.AspNetCore.Authentication.Cookies;
13 | using Microsoft.AspNetCore.Authentication.JwtBearer;
14 | using Microsoft.IdentityModel.Tokens;
15 | using System.Text;
16 | using Microsoft.AspNetCore.Http;
17 | using System.Security.Cryptography.X509Certificates;
18 |
19 | namespace webapi
20 | {
21 |
22 | public class Startup
23 | {
24 | public static string clientid, authority, adminconsent, resource, secret, issuerSigningKey, tenantid, validissuer, validAudience;
25 |
26 | public Startup(IConfiguration configuration)
27 | {
28 | Configuration = configuration;
29 |
30 | #region parameters
31 | clientid = "{{clientId}}";
32 | secret = "{{secret}}";
33 | tenantid = "{{tenantid}}";
34 |
35 | //#if(instance=="global")
36 | authority = "https://login.microsoftonline.com/common";
37 | resource = "https://graph.microsoft.com";
38 | validissuer = "https://sts.windows.net/{{tenantid}}/";
39 | validAudience = "https://office365devlabs.onmicrosoft.com/TodoListService-OBO";//请修改成自己的service
40 |
41 | //#else
42 | authority = "https://login.chinacloudapi.cn/common";
43 | resource = "https://microsoftgraph.chinacloudapi.cn";
44 | validissuer = "https://sts.chinacloudapi.cn/{{tenantid}}/";
45 | validAudience = "https://modtsp.partner.onmschina.cn/dotnet-obo-webapi";
46 | //#endif
47 | #endregion
48 |
49 | }
50 |
51 | public IConfiguration Configuration { get; }
52 |
53 | // This method gets called by the runtime. Use this method to add services to the container.
54 | public void ConfigureServices(IServiceCollection services)
55 | {
56 |
57 | services.AddAuthentication(options =>
58 | {
59 | options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
60 | options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
61 | })
62 | .AddJwtBearer(o =>
63 | {
64 | o.Authority = authority;
65 | o.Audience = validAudience;
66 | o.TokenValidationParameters = new TokenValidationParameters()
67 | {
68 | ValidIssuer = validissuer
69 | };
70 | });
71 | services.AddMvc();
72 | }
73 |
74 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
75 | public void Configure(IApplicationBuilder app, IHostingEnvironment env)
76 | {
77 | if (env.IsDevelopment())
78 | {
79 | app.UseDeveloperExceptionPage();
80 | }
81 |
82 | app.UseAuthentication();
83 |
84 | app.UseMvc();
85 | }
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Views/Shared/_Layout.cshtml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | @ViewData["Title"] - content
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
39 |
40 |
41 | @RenderBody()
42 |
43 |
44 | © 2018 - content
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
60 |
66 |
67 |
68 |
69 | @RenderSection("Scripts", required: false)
70 |
71 |
72 |
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/webapi.csproj.nuget.g.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/lang/zh-cn/README.md:
--------------------------------------------------------------------------------
1 | # Office 365 应用开发的 .NET Core 模板库
2 |
3 | [English](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/README.md) | 简体中文 | [繁體中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/lang/zh-tw/README.md)
4 |
5 | > 作者:陈希章 发表于 2018年4月22日
6 |
7 | ## 概述
8 |
9 | 前不久我写过一篇文章[拥抱开源,Office 365开发迎来新时代](https://github.com/chenxizhang/office365dev/blob/master/docs/office365opensource.md),给大家介绍了Office 365开发的典型场景是如何支持开源平台的:Office 365通过Microsoft Graph,以REST API的方式提供服务,任何开发平台都可以很方便地与其进行集成;Office Add-ins,SharePoint Add-ins和Microsoft Teams Apps开发,都可以基于标准的Web开发技术栈来实现,而且官方提供了对NodeJS,React,TypeScript等主流平台和框架的默认支持(工具和模板层面都有)。
10 |
11 | 文章发表之后,我收到不少反馈,其实我内心深处牵挂的还有广大的.NET开发人员啊。大家知道,.NET从头到脚都是已经完全开源了的,针对Office 365的这些开发场景,是否有开箱即用的模板可供大家使用呢?利用周末的时间,我开始了这个新的项目,就是为大家整理出来一套标准的.NET Core模板库,欢迎用你最熟悉的姿势关注 ,你可以简单粗暴地直接给我 `star`,也可以 `fork` 这个项目通过 `pull request` 提交你的模板,你还可以通过`issue`通道给我反馈问题。
12 |
13 | 这一套模板库,不仅仅可以降低广大的.NET 开发人员(准确地说是.NET Core开发人员)学习和使用Office 365开发平台的门槛(尤其是如何在不同的场景下完成OAuth认证以及快速通过实例学习Graph的典型功能),还有一个独特的价值是可以让你在国际版和国内版这两个平台的选择和切换过程中少走一些弯路,我相信真正做过这方面开发的朋友们现在一定是热泪盈眶的表情。
14 |
15 | 希望大家喜欢!
16 |
17 | ## 计划支持的模板
18 |
19 | |模板|模板标识|模板短名称|国际版|国内版|
20 | |:---|:---|:---|:---|:---|
21 | |控制台应用程序(Graph)|chenxizhang. dotnetcore. msgraph. console. CSharp|[graphconsole](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-console/README.md)|支持|支持|
22 | |无人值守应用程序(Graph)|chenxizhang. dotnetcore. msgraph. serviceapp. CSharp|[graphserviceapp](https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-serviceapp/README.md)|支持|支持|
23 | |ASP.NET Web应用程序(Graph)|chenxizhang. dotnetcore. msgraph. webapp. CSharp|[graphwebapp](https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-webapp/README.md)|支持|支持|
24 | |ASP.NET MVC应用程序(Graph)|chenxizhang. dotnetcore. msgraph. mvcapp. CSharp|[graphmvcapp](https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-mvcapp/README.md)|支持|支持|
25 | |ASP.NET Web API 应用程序(Graph)|chenxizhang. dotnetcore. msgraph. mvcapi. CSharp|[graphwebapi](https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-webapi/README.md)|支持|支持|
26 |
27 | ## 先决条件
28 |
29 | 要使用这些模板,你只需要在开发机器上面安装了 .NET Core SDK 版本2.0 及以上即可。请通过官方网站提示到的方式进行下载和安装( )。请注意,我们现在是跨平台的哦,无论Windows,还是Mac,或是Linux都支持进行.NET Core开发,与此同时, .NET Core应用程序可以使用`docker`进行部署,其开发和部署、运营流程结合`devops`也是如丝般润滑的。
30 |
31 | 另外,你可能至少需要一款代码编辑器,你可以安装Visual Studio,也可以使用Visual Studio Code,甚至是任何一个文本编辑器。我是使用 [Visual Studio Code](http://code.visualstudio.com/).
32 |
33 | ## 如何安装模板
34 |
35 | 安装这些模板非常简单,你只需要一行命令即可,`dotnet new -i 模板标识`,例如使用`dotnet new -i chenxizhang.dotnetcore.msgraph.console.CSharp` 来安装可以快速实现Microsoft Graph的控制台应用程序模板。
36 |
37 | ## 如何使用模板
38 |
39 | 模板安装成功后,你可以在模板列表中看到这些新的模板,每个模板都有一个短名称(Short Name),你可以通过 `dotnet new 模板短名称`来使用这些模板,例如 `dotnet new graphconsole` 这句命令就可以快速基于模板创建一个可以快速实现Microsoft Graph的控制台应用程序。
40 |
41 | 每个模板都带有一些参数以便支持不同的场景,最典型的参数是 `--instance`,这个参数将告诉模板引擎,你使用的Office 365环境是国际版还是国内版的,它是一个必填项,有两个选项,分别是`global`代表国际版,`gallatin`代表国内版,但默认会设置为国际版。
42 |
43 | 你不需要记住所有这些参数,而是可以通过 `dotnet new 模板短名称 -h`这样的命令来查看该模板的介绍和参数说明。
44 |
45 | 每个模板都带有一个详细的说明文档,你可以点击上表中模板短名称跳转,同时在生成的代码文件的顶部也有链接,我非常欢迎大家给我反馈。
46 |
47 | ## 如何卸载模板
48 |
49 | 在如下两种情况下,你可能需要卸载模板
50 |
51 | 1. 你不再喜欢这些模板(我希望这种情况不会发生)
52 | 1. 你需要安装模板的更新版本
53 |
54 | 无论是哪一种原因,你都可以随时简单地通过 `dotnet new -u 模板标识` 进行卸载,例如`dotnet new -u chenxizhang.dotnetcore.msgraph.console.CSharp`可以卸载控制台应用程序模板。请放心,我不会带走一片云彩。
55 |
56 | ## 常见问题解答(将持续更新)
57 |
58 | 1. 这些模板支持哪些开发语言?
59 | >目前仅支持C#。限于能力和精力,其他的语言暂时没有支持计划,欢迎有其他语言特长(例如F#,VB.NET等)的朋友参与该项目。
--------------------------------------------------------------------------------
/lang/zh-tw/README.md:
--------------------------------------------------------------------------------
1 | # Office 365 應用開發的 .NET Core 模板庫
2 |
3 | [English](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/README.md) | [简体中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/lang/zh-cn/README.md) | 繁體中文
4 |
5 | > 作者:陳希章 發表於 2018年4月22日
6 |
7 | ## 概述
8 |
9 | 前不久我寫過壹篇文章[擁抱開源,Office 365開發迎來新時代](https://github.com/chenxizhang/office365dev/blob/master/docs/office365opensource.md),給大家介紹了Office 365開發的典型場景是如何支持開源平臺的:Office 365通過Microsoft Graph,以REST API的方式提供服務,任何開發平臺都可以很方便地與其進行集成;Office Add-ins,SharePoint Add-ins和Microsoft Teams Apps開發,都可以基於標準的Web開發技術棧來實現,而且官方提供了對NodeJS,React,TypeScript等主流平臺和框架的默認支持(工具和模板層面都有)。
10 |
11 | 文章發表之後,我收到不少反饋,其實我內心深處牽掛的還有廣大的.NET開發人員啊。大家知道,.NET從頭到腳都是已經完全開源了的,針對Office 365的這些開發場景,是否有開箱即用的模板可供大家使用呢?利用周末的時間,我開始了這個新的項目,就是為大家整理出來壹套標準的.NET Core模板庫,歡迎用妳最熟悉的姿勢關註 ,妳可以簡單粗暴地直接給我 `star`,也可以 `fork` 這個項目通過 `pull request` 提交妳的模板,妳還可以通過`issue`通道給我反饋問題。
12 |
13 | 這壹套模板庫,不僅僅可以降低廣大的.NET 開發人員(準確地說是.NET Core開發人員)學習和使用Office 365開發平臺的門檻(尤其是如何在不同的場景下完成OAuth認證以及快速通過實例學習Graph的典型功能),還有壹個獨特的價值是可以讓妳在國際版和國內版這兩個平臺的選擇和切換過程中少走壹些彎路,我相信真正做過這方面開發的朋友們現在壹定是熱淚盈眶的表情。
14 |
15 | 希望大家喜歡!
16 |
17 | ## 計劃支持的模板
18 |
19 | |模板|模板標識|模板短名稱|國際版|國內版|
20 | |:---|:---|:---|:---|:---|
21 | |控制臺應用程序(Graph)|chenxizhang. dotnetcore. msgraph. console. CSharp|[graphconsole](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-console/README.md)|支持|支持|
22 | |無人值守應用程序(Graph)|chenxizhang. dotnetcore. msgraph. serviceapp. CSharp|[graphserviceapp](https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-serviceapp/README.md)|支持|支持|
23 | |ASP.NET Web應用程序(Graph)|chenxizhang. dotnetcore. msgraph. webapp. CSharp|[graphwebapp](https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-webapp/README.md)|支持|支持|
24 | |ASP.NET MVC應用程序(Graph)|chenxizhang. dotnetcore. msgraph. mvcapp. CSharp|[graphmvcapp](https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-mvcapp/README.md)|支持|支持|
25 | |ASP.NET Web API 應用程序(Graph)|chenxizhang. dotnetcore. msgraph. mvcapi. CSharp|[graphwebapi](https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-webapi/README.md)|支持|支持|
26 |
27 | ## 先決條件
28 |
29 | 要使用這些模板,妳只需要在開發機器上面安裝了 .NET Core SDK 版本2.0 及以上即可。請通過官方網站提示到的方式進行下載和安裝( )。請註意,我們現在是跨平臺的哦,無論Windows,還是Mac,或是Linux都支持進行.NET Core開發,與此同時, .NET Core應用程序可以使用`docker`進行部署,其開發和部署、運營流程結合`devops`也是如絲般潤滑的。
30 |
31 | 另外,妳可能至少需要壹款代碼編輯器,妳可以安裝Visual Studio,也可以使用Visual Studio Code,甚至是任何壹個文本編輯器。我是使用 [Visual Studio Code](http://code.visualstudio.com/).
32 |
33 | ## 如何安裝模板
34 |
35 | 安裝這些模板非常簡單,妳只需要壹行命令即可,`dotnet new -i 模板標識`,例如使用`dotnet new -i chenxizhang.dotnetcore.msgraph.console.CSharp` 來安裝可以快速實現Microsoft Graph的控制臺應用程序模板。
36 |
37 | ## 如何使用模板
38 |
39 | 模板安裝成功後,妳可以在模板列表中看到這些新的模板,每個模板都有壹個短名稱(Short Name),妳可以通過 `dotnet new 模板短名稱`來使用這些模板,例如 `dotnet new graphconsole` 這句命令就可以快速基於模板創建壹個可以快速實現Microsoft Graph的控制臺應用程序。
40 |
41 | 每個模板都帶有壹些參數以便支持不同的場景,最典型的參數是 `--instance`,這個參數將告訴模板引擎,妳使用的Office 365環境是國際版還是國內版的,它是壹個必填項,有兩個選項,分別是`global`代表國際版,`gallatin`代表國內版,但默認會設置為國際版。
42 |
43 | 妳不需要記住所有這些參數,而是可以通過 `dotnet new 模板短名稱 -h`這樣的命令來查看該模板的介紹和參數說明。
44 |
45 | 每個模板都帶有壹個詳細的說明文檔,妳可以點擊上表中模板短名稱跳轉,同時在生成的代碼文件的頂部也有鏈接,我非常歡迎大家給我反饋。
46 |
47 | ## 如何卸載模板
48 |
49 | 在如下兩種情況下,妳可能需要卸載模板
50 |
51 | 1. 妳不再喜歡這些模板(我希望這種情況不會發生)
52 | 1. 妳需要安裝模板的更新版本
53 |
54 | 無論是哪壹種原因,妳都可以隨時簡單地通過 `dotnet new -u 模板標識` 進行卸載,例如`dotnet new -u chenxizhang.dotnetcore.msgraph.console.CSharp`可以卸載控制臺應用程序模板。請放心,我不會帶走壹片雲彩。
55 |
56 | ## 常見問題解答(將持續更新)
57 |
58 | 1. 這些模板支持哪些開發語言?
59 | >目前僅支持C#。限於能力和精力,其他的語言暫時沒有支持計劃,歡迎有其他語言特長(例如F#,VB.NET等)的朋友參與該項目。
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Views/Home/Index.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "Home Page";
3 | }
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | Learn how to build ASP.NET apps that can run anywhere.
18 |
19 | Learn More
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | There are powerful new features in Visual Studio for building modern web apps.
29 |
30 | Learn More
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | Bring in libraries from NuGet and npm, and automate tasks using Grunt or Gulp.
40 |
41 | Learn More
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | Learn how Microsoft's Azure cloud platform allows you to build, deploy, and scale web apps.
51 |
52 | Learn More
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | Previous
61 |
62 |
63 |
64 | Next
65 |
66 |
67 |
68 |
69 |
70 |
User Profile
71 | @ViewBag.me.DisplayName,@ViewBag.me.UserPrincipalName
72 |
73 |
74 |
My Inbox
75 |
76 | @foreach(var item in @ViewBag.messages){
77 | @item.Subject
78 | }
79 |
80 |
81 |
82 |
My Files
83 |
84 | @foreach(var item in @ViewBag.files){
85 | @item.Name
86 | }
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph ASP.NET MVC Application Template
2 |
3 | English | [简体中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-mvcapp/lang/zh-cn/README.md) | [繁體中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-mvcapp/lang/zh-tw/README.md)
4 |
5 | > Author:Ares Chen @ 2018/4/26
6 |
7 | ## Overview
8 |
9 | This project template can help you quickly set up an ASP.NET MVC website and call the Microsoft Graph service as a user, implementing the following three functions:
10 |
11 | 1. Read the basic information of the current user
12 | 1. Read the first ten messages in the current user's mailbox inbox (Exchange Online)
13 | 1. Read the list of files under the root directory of the current user's OneDrive for Business
14 |
15 | The template supports both ``global`` and ``gallatin`` versions.
16 |
17 | ## Prerequisites
18 |
19 | In order to use this template, you'd better be able to register an application yourself. If you are not familiar with this concept, please refer to the description of [Microsoft Graph overview] (https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md).
20 |
21 | If you need to access the ``global`` version of Office 365, it is recommended that you directly use the AAD 2.0 registration method to register at . Please refer to [this article] (https://github) .com/chenxizhang/office365dev/blob/master/docs/applicationregisteration2.0.md).
22 |
23 | If you need to access the ``gallatin`` version of Office 365, you can only use the AAD 1.0 registration method to register at , please refer to [this article] (https://github. Com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md).
24 |
25 | This template example requires at least three delegated permissions
26 |
27 | 1. Files.Read.All
28 | 1. Mail.Read
29 | 1. User.Read
30 |
31 | Regardless of which method you use for registration, please set Reply Url to .
32 |
33 | ## How to install the template
34 |
35 | You can install this template through `dotnet new -i chenxizhang.dotnetcore.msgraph.mvcapp.CSharp`.
36 |
37 | ## How to use the template
38 |
39 | There are several scenarios for this template, as follows
40 |
41 | 1. The simplest usage of `dotnet new graphmvcapp` will create a template implementation, and you will use the clientid I created in advance to access Office 365 International.
42 | 1. By explicitly specifying the `clientid` and `secret` parameter, explicitly use your application to access Office 365. This is my most recommended, the syntax is `dotnet new graphmvcapp --clientid' the-applicationid-you-created --secret your-secret`.
43 | 1. With the `instance` parameter, specify whether you want to access the ``global`` or ``gallatin`` version. The ``global`` version is the default, and if you want to specify the ``gallatin`` version, you need to use the following syntax: `dotnet new graphmvcapp --instance gallatin --clientid the-applicationid-you-created --secret your-secret`.
44 | 1. Specify the version of the Graph API you want to access via the `version` parameter. The default is `v1.0`. Currently `beta` is also supported.
45 |
46 | There are also two common parameters
47 |
48 | 1. By specifying `name` you can change the name of the project generated by the template, as well as the default namespace name. For example, `dotnet new graphmvcapp -n mynamespace`.
49 | 1. You can specify to generate a new project directory by specifying `output`. For example, `dotnet new graphmvcapp -o test`.
50 |
51 | Once the project is created, you can run it directly from `dotnet run` or edit it in `Visual Studio Code` and run it again. You will see the current user information, email information and file list on the home page.
52 |
53 | ## How to uninstall the template
54 |
55 | You can uninstall this template through `dotnet new -u chenxizhang.dotnetcore.msgraph.mvcapp.CSharp`.
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph Web API Template
2 |
3 | [English](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapi/README.md) | [简体中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapi/lang/zh-cn/README.md) | [繁體中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapi/lang/zh-tw/README.md)
4 |
5 | > Author:Ares Chen @ 2018/5/1
6 |
7 | ## Overview
8 |
9 | This project template can help you quickly create a web api project, and can accept client calls, through the On-Behalf-Of grant flow to achieve the function of calling a Microsoft Graph as a user, to achieve the following function
10 |
11 | 1. Read the basic information of the current user
12 |
13 | The template supports both ``global`` and `gallatin` versions.
14 |
15 | ## Preparation
16 |
17 | In order to use this template, you'd better be able to register an application yourself. If you are not familiar with this concept, please refer to the description of [Microsoft Graph overview] (https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md).
18 |
19 | Regardless of whether you are using an international or a domestic version, you can only use the AAD 1.0 registration method at . Please refer to [this article] (https://github.com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md).
20 |
21 | This template example requires at least one delegated permission
22 |
23 | 1. User.Read
24 |
25 | This template implements a complete On-Behalf-Of grant flow. That is, the client application obtains the access permission from Azure AD first, and then when the middle-tier service is invoked, the service layer uses the client's Access_Token to exchange itself. The Access_Token looks as if the client is accessing it. About this scenario, and how to configure On-Behalf-Of applications and permissions, please refer to the description here. You need to register two applications.
26 |
27 | ## Installation
28 |
29 | You can install this project template with `dotnet new -i chenxizhang.dotnetcore.msgraph.webapi.CSharp`.
30 |
31 | ## Use
32 |
33 | There are several scenarios for this template, as follows
34 |
35 | 1. The simplest usage `dotnet new graphwebapi` will create a template implementation that you will use to access Office 365 International using a clientid I created in advance.
36 | 1. By explicitly specifying the `clientid` and `secret` parameters, the `tenantid` parameter, and the `obo-console-clientid` parameter, explicitly use your application to access Office 365. This is what I recommend most, the syntax is dotnet New graphwebapi --clientid The application number you created --secret your key --tenantid your tenant number --obo-console-clientid the application number you registered for the client. On how to get `tenantid`, you can also get it through the PowerShell method described in [my article] (http://www.cnblogs.com/chenxizhang/p/7904293.html).
37 | 1. With the `instance` parameter, specify whether you want to access the international or domestic version. The international version is the default, and if you want to specify the domestic version, you need to use the following syntax: `dotnet new graphwebapi --instance gallatin --clientid your-applicationid --secret your-key`.
38 | 1. Specify the version of the Graph API you want to access via the `version` parameter. The default is `v1.0`. Currently `beta` is also supported.
39 |
40 | There are also two common parameters
41 |
42 | 1. By specifying `name` you can change the name of the project generated by the template, as well as the default namespace name. For example, `dotnet new graphwebapi -n mynamespace`.
43 | 1. You can specify to generate a new project directory by specifying ʻoutput`. For example, `dotnet new graphwebapi -o test`.
44 |
45 | Once the project is created, you can run it directly from `dotnet run` or edit it in `Visual Studio Code` and run it again.
46 |
47 | 1. Read the basic information of the current user
48 |
49 | ## Uninstall
50 |
51 | You can uninstall the current project template with `dotnet new -u chenxizhang.dotnetcore.msgraph.webapi.CSharp`.
--------------------------------------------------------------------------------
/dotnetcore-graph-webapp/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph ASP.NET Web Site Template
2 |
3 | English | [简体中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapp/lang/zh-cn/README.md) | [繁體中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-webapp/lang/zh-tw/README.md)
4 |
5 | > Author:Ares Chen @ 2018/4/28
6 |
7 | ## Overview
8 |
9 | This project template can help you quickly set up an ASP.NET website and call the Microsoft Graph service as a user, implementing the following three functions:
10 |
11 | 1. Read the basic information of the current user
12 | 1. Read the first ten messages in the current user's mailbox inbox (Exchange Online)
13 | 1. Read the list of files under the root directory of the current user's OneDrive for Business
14 |
15 | The template supports both ``global`` and ``gallatin`` versions.
16 |
17 | ## Prerequisites
18 |
19 | In order to use this template, you'd better be able to register an application yourself. If you are not familiar with this concept, please refer to the description of [Microsoft Graph overview] (https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md).
20 |
21 | If you need to access the ``global`` version of Office 365, it is recommended that you directly use the AAD 2.0 registration method to register at . Please refer to [this article] (https://github) .com/chenxizhang/office365dev/blob/master/docs/applicationregisteration2.0.md).
22 |
23 | If you need to access the ``gallatin`` version of Office 365, you can only use the AAD 1.0 registration method to register at , please refer to [this article] (https://github. Com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md).
24 |
25 | This template example requires at least three delegated permissions
26 |
27 | 1. Files.Read.All
28 | 1. Mail.Read
29 | 1. User.Read
30 |
31 | Regardless of which method you use for registration, please set Reply Url to .
32 |
33 | ## How to install the template
34 |
35 | You can install this template through `dotnet new -i chenxizhang.dotnetcore.msgraph.webapp.CSharp`.
36 |
37 | ## How to use the template
38 |
39 | There are several scenarios for this template, as follows
40 |
41 | 1. The simplest usage of `dotnet new graphwebapp` will create a template implementation, and you will use the clientid I created in advance to access Office 365 International.
42 | 1. By explicitly specifying the `clientid` and `secret` parameter, explicitly use your application to access Office 365. This is my most recommended, the syntax is `dotnet new graphwebapp --clientid' the-applicationid-you-created --secret your-secret`.
43 | 1. With the `instance` parameter, specify whether you want to access the ``global`` or ``gallatin`` version. The ``global`` version is the default, and if you want to specify the ``gallatin`` version, you need to use the following syntax: `dotnet new graphwebapp --instance gallatin --clientid the-applicationid-you-created --secret your-secret`.
44 | 1. Specify the version of the Graph API you want to access via the `version` parameter. The default is `v1.0`. Currently `beta` is also supported.
45 |
46 | There are also two common parameters
47 |
48 | 1. By specifying `name` you can change the name of the project generated by the template, as well as the default namespace name. For example, `dotnet new graphwebapp -n mynamespace`.
49 | 1. You can specify to generate a new project directory by specifying `output`. For example, `dotnet new graphwebapp -o test`.
50 |
51 | Once the project is created, you can run it directly from `dotnet run` or edit it in `Visual Studio Code` and run it again. You can access the three default features through the following address:
52 |
53 | 1. Read the current user's basic information ()
54 | 1. Read the first ten messages in the current user's mailbox (Exchange Online) ()
55 | 1. Read the list of files under the root directory of the current user's OneDrive for Business ()
56 |
57 | ## How to uninstall the template
58 |
59 | You can uninstall this template through `dotnet new -u chenxizhang.dotnetcore.msgraph.webapp.CSharp`.
--------------------------------------------------------------------------------
/dotnetcore-graph-console/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph Console Application Template
2 |
3 | English | [简体中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-console/lang/zh-cn/README.md) | [繁體中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-console/lang/zh-tw/README.md)
4 |
5 | > Author:Ares Chen @ 2018/4/22
6 |
7 | ## Overview
8 |
9 | This project template can help you quickly build a console application and call a Microsoft Graph service on-behalf of a user, The template implementing the following three functions:
10 |
11 | 1. Read the basic information of the current user
12 | 1. Read the first ten messages in the current user's mailbox inbox (Exchange Online)
13 | 1. Read the list of files under the root directory of the current user's OneDrive for Business
14 |
15 | Since .NET Core is to be cross-platform, the pop-up window provided in the native Windows operating system cannot be used for user login. This template is implemented in a special way. After the program runs, a `device code` will be automatically generated and the user will be prompted with a login webpage address. The user enters the `device code` on the webpage and will be directed to the corresponding Office 365 landing page. After the authentication and authorization are completed, the console program is executed. You will receive the notification and get the Access Token. Then you can invoke the Microsoft Graph.
16 |
17 | The template supports both `global` and `gallatin` office 365 environment.
18 |
19 | ## Prerequisites
20 |
21 | In order to use this template, you'd better be able to register an application yourself. If you are not familiar with this concept, please refer to the description of [Microsoft Graph overview] (https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md).
22 |
23 | If you need to access the international version of Office 365, it is recommended that you directly use the AAD 2.0 registration method to register at . Please refer to [this article] (https://github) .com/chenxizhang/office365dev/blob/master/docs/applicationregisteration2.0.md).
24 |
25 | If you need to access the domestic version of Office 365, you can only use the AAD 1.0 registration method to register at , please refer to [this article] (https://github. Com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md).
26 |
27 | This template example requires at least three delegated permissions
28 |
29 | 1. Files.Read.All
30 | 1. Mail.Read
31 | 1. User.Read
32 |
33 | ## How to install the template
34 |
35 | You can install this template through `dotnet new -i chenxizhang.dotnetcore.msgraph.console.CSharp`.
36 |
37 | ## How to use the template
38 |
39 | There are several scenarios for this template, as follows
40 |
41 | 1. The simplest usage of `dotnet new graphconsole` will create a template implementation, and you will use the clientid I created in advance to access Office 365 International.
42 | 1. By explicitly specifying the `clientid` parameter, explicitly use your application to access Office 365. This is my most recommended, the syntax is `dotnet new graphconsole --clientid' the-applicationid-you-created`.
43 | 1. With the `instance` parameter, specify whether you want to access the ``global`` or ``gallatin`` version. The ``global`` version is the default, and if you want to specify the ``gallatin`` version, you need to use the following syntax: `dotnet new graphconsole --instance gallatin --clientid the-applicationid-you-created`.
44 | 1. Specify the version of the Graph API you want to access via the `version` parameter. The default is `v1.0`. Currently `beta` is also supported.
45 |
46 | There are also two common parameters
47 |
48 | 1. By specifying `name` you can change the name of the project generated by the template, as well as the default namespace name. For example, `dotnet new graphconsole -n mynamespace`.
49 | 1. You can specify to generate a new project directory by specifying `output`. For example, `dotnet new graphconsole -o test`.
50 |
51 | Once the project is created, you can run it directly from `dotnet run` or edit it in `Visual Studio Code` and run it again.
52 |
53 | ## How to uninstall the template
54 |
55 | You can uninstall this template through `dotnet new -u chenxizhang.dotnetcore.msgraph.console.CSharp`.
--------------------------------------------------------------------------------
/dotnetcore-graph-webapi/content/webapi/obj/webapi.csproj.nuget.g.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | True
5 | NuGet
6 | C:\temp\dotnetcore-graph-webapi\content\webapi\obj\project.assets.json
7 | $(UserProfile)\.nuget\packages\
8 | C:\Users\arechen\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder
9 | PackageReference
10 | 4.9.2
11 |
12 |
13 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.entityframeworkcore.tools\2.2.0
26 | C:\Users\arechen\.nuget\packages\microsoft.codeanalysis.analyzers\1.1.0
27 | C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.razor.design\2.2.0
28 |
29 |
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/README.md:
--------------------------------------------------------------------------------
1 | # Microsoft Graph Deamon Application Template
2 |
3 | English | [简体中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-serviceapp/lang/zh-cn/README.md) | [繁體中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-serviceapp/lang/zh-tw/README.md)
4 |
5 | > Author:Ares Chen @ 2018/4/22
6 |
7 | ## Overview
8 |
9 | A deamon application refers to a type of application that does not require user interaction. They are likely to run in the background with a timer. Due to this feature, they often do not access a Microsoft Graph as a specific user, but rather as a fixed identity. In this project template, we implement the standard Client Credential authentication process in Oauth 2.0, that is, the application uses its own application number (`clientid`), and a key (`secret`) to indicate its own Identity, and the permissions it gets, after being confirmed by the Office 365 administrator, can access any user's data.
10 |
11 | This template implements five basic functions
12 |
13 | 1. Read all user information
14 | 1. Read a user's inbox mailing list
15 | 1. Read the file list of a user's personal network disk root directory
16 | 1. Send mail on behalf of a user
17 | 1. Upload a text file to a user's personal web drive
18 |
19 | ## Prerequisites
20 |
21 | In order to use this template, you'd better be able to register an application yourself. If you are not familiar with this concept, please refer to the description of [Microsoft Graph overview] (https://github.com/chenxizhang/office365dev/blob/master/docs/microsoftgraphoverview.md).
22 |
23 | If you need to access the international version of Office 365, it is recommended that you directly use the AAD 2.0 registration method to register at . Please refer to [this article] (https://github) .com/chenxizhang/office365dev/blob/master/docs/applicationregisteration2.0.md).
24 |
25 | If you need to access the domestic version of Office 365, you can only use the AAD 1.0 registration method to register at , please refer to [this article] (https://github. Com/chenxizhang/office365dev/blob/master/docs/applicationregisteration.md).
26 |
27 | This template example requires at least five application permissions
28 |
29 | 1. Files.Read.All(Admin)
30 | 1. Mail.Read(Admin)
31 | 1. User.Read.All(Admin)
32 | 1. Mail.Send(Admin)
33 | 1. File.ReadWrite.All(Admin)
34 |
35 | Please note that this type of application permission requires an "Admin consent" from Office 365 management. After the project is generated, there will be operational hints in this area.
36 |
37 | ## How to install the template
38 |
39 | You can install this template through `dotnet new -i chenxizhang.dotnetcore.msgraph.serviceapp.CSharp`.
40 |
41 | ## How to use the template
42 |
43 | The project template defines five parameters, which are as follows
44 |
45 | 1. `instance`, used to define the version of the target Office 365 environment, `global` for the international version (default), and `gallatin` for the domestic version.
46 | 1. `clientid`, the application number obtained when registering the application.
47 | 1. `secret`, the key generated when registering the application.
48 | 1. `tenantid` specifies the tenant id you want to access last. Unlike delegated permissions, application permissions must be explicitly limited to specific tenants rather than multi-tenants. There are several ways to get this tenantid, one is when you are doing Admin consent, and there is this information in the address column of the returned result. You can also get it through the PowerShell method described in [my article] (http://www.cnblogs.com/cn/xixizhang/p/7904293.html).
49 | 1. `version` specifies the version of the Graph API you want to access. The default is `v1.0` and currently supports `beta`.
50 |
51 | If you are not quite sure how to register the application and how to do Admin consent, you can directly run the most basic command `dotnet new graphserviceapp` and use the environment I have configured to experience these functions.
52 | > My test environment is often modified and may be expired, so you may experience situations where you are unable to work properly.
53 |
54 | The regular use of this template is to specify at least the first four parameters, such as `dotnet new graphserviceapp --instance gallatin --clientid your-application-id --secret your-secret --tenantid your-tenantid`.
55 |
56 | There are also two common parameters
57 |
58 | 1. By specifying `name` you can change the name of the project generated by the template, as well as the default namespace name. For example, `dotnet new graphserviceapp -n myserviceapp`.
59 | 1. You can specify to generate a new project directory by specifying `output`. For example, `dotnet new graphserviceapp -o testapp`.
60 |
61 | In addition, please note that after the project is generated, you can't directly run `dotnet run`, but at least modify two lines of code (lines 72, 73) to set the user upn and mail recipient information you want to access.
62 |
63 | ## How to uninstall the template
64 |
65 | You can uninstall this template through `dotnet new -u chenxizhang.dotnetcore.msgraph.serviceapp.CSharp`.
--------------------------------------------------------------------------------
/dotnetcore-graph-serviceapp/content/Program.cs:
--------------------------------------------------------------------------------
1 | /*
2 | 作者:陈希章 Ares Chen
3 | 时间:2018年4月22日
4 | 说明:
5 | 这是一个可以快速通过Microsoft Graph访问到Office 365资源的服务应用程序模板,通常理解为无人值守自动运行的程序。
6 | 由于是一个无人值守的应用程序,所以不需要用户输入账号或者密码,该模板使用了应用程序密钥作为身份凭据。为了使用该应用程序,你需要得到Office 365管理员的授权确认。
7 | 目前该模板同时支持国际版和国内版。
8 |
9 | 关于此模板的使用以及问题反馈,请访问 https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-serviceapp
10 | Office 365开发入门指南,请参考 https://github.com/chenxizhang/office365dev
11 | 更多模板请参考 https://github.com/chenxizhang/dotnetcore-office365dev-templates
12 | */
13 | using System;
14 | using Microsoft.IdentityModel.Clients.ActiveDirectory;
15 | using Microsoft.Graph;
16 | using System.Threading.Tasks;
17 | using System.Net.Http.Headers;
18 | using System.Linq;
19 | using System.IO;
20 | using System.Text;
21 |
22 |
23 | namespace content
24 | {
25 | class Program
26 | {
27 | static void Main(string[] args)
28 | {
29 | #region parameters
30 | string clientId,authority,adminconsent,resource,secret;
31 | clientId ="{{clientId}}";
32 | secret ="{{secret}}";
33 |
34 | //#if(instance=="global")
35 | //注册一个native app,申请应用程序权限,管理员确认,申请一个密钥
36 |
37 | adminconsent ="https://login.microsoftonline.com/common/adminconsent?client_id={{clientId}}&state=12345&redirect_uri=http://localhost";
38 | authority ="https://login.microsoftonline.com/{{tenantid}}/oauth2";
39 | resource="https://graph.microsoft.com";
40 |
41 |
42 | //#else
43 | adminconsent ="https://login.chinacloudapi.cn/common/adminconsent?client_id={{clientId}}&state=12345&redirect_uri=http://localhost";
44 | authority ="https://login.chinacloudapi.cn/{{tenantid}}/oauth2";
45 | resource="https://microsoftgraph.chinacloudapi.cn";
46 | //#endif
47 | #endregion
48 |
49 | Console.WriteLine($"欢迎使用该模板,请注意,服务应用申请的权限,需要Office 365管理员进行授权。如果你还没有授权,请访问 {adminconsent}");
50 | Console.WriteLine("该模板要求修改代码中的用户及邮箱信息,确认请按任意键继续,否则请取消(Ctrl+C)");
51 | Console.ReadKey();
52 |
53 | var token = "";
54 | var client = new GraphServiceClient(new DelegateAuthenticationProvider(async (request) =>
55 | {
56 | if (string.IsNullOrEmpty(token))
57 | {
58 | var ctx = new AuthenticationContext(authority: authority);
59 | token = (await ctx.AcquireTokenAsync(resource,new ClientCredential(clientId,secret))).AccessToken;
60 | }
61 |
62 | request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
63 | await Task.FromResult(0);
64 | }))
65 | {
66 | BaseUrl = $"{resource}/{{version}}"
67 | };
68 |
69 | Console.WriteLine("读取所有用户基本信息");
70 | //读取所有用户信息
71 | var users = client.Users.Request().GetAsync().Result;
72 | foreach (var item in users)
73 | {
74 | Console.WriteLine($"\t{item.DisplayName}");
75 | }
76 |
77 |
78 | var testuserupn ="测试用户的upn,请修改";
79 | var emailtoaddress="邮件收件人邮箱,请修改";
80 |
81 |
82 | Console.WriteLine("\n读取某个用户的邮件列表(第一页)");
83 |
84 | //读取第一个用户的邮件
85 | var messages = client.Users[testuserupn].Messages.Request().GetAsync().Result;
86 | foreach (var item in messages)
87 | {
88 | Console.WriteLine($"\t{item.Subject}");
89 | }
90 |
91 | Console.WriteLine("\n读取某个用户的个人网盘");
92 | //读取第一个用户的个人网盘
93 | var files = client.Users[testuserupn].Drive.Root.Children.Request().GetAsync().Result;
94 | foreach (var item in files)
95 | {
96 | Console.WriteLine($"\t{item.Name}");
97 | }
98 |
99 | Console.WriteLine("\n代表某个用户发送一封测试邮件");
100 | //代表第一个用户发邮件
101 | var message =new Message(){
102 | Subject ="通过服务程序发出来的邮件",
103 | ToRecipients = new[]{
104 | new Recipient(){
105 | EmailAddress =new EmailAddress(){Address =emailtoaddress}
106 | }
107 | }
108 | };
109 |
110 | client.Users[testuserupn].SendMail(message,true).Request().PostAsync().Wait();
111 | System.Console.WriteLine("\t发送成功");
112 |
113 | Console.WriteLine("\n代表某个用户上传一个文件到个人网盘");
114 | //上传一个文件到第一个用户的个人网盘
115 | using(var stream =new MemoryStream()){
116 | var content = $"Hello, {DateTime.Now.ToLongDateString()} ";
117 | var buffer = Encoding.UTF8.GetBytes(content);
118 | stream.Write(buffer,0,buffer.Length);
119 | stream.Position =0;
120 |
121 | client.Users[testuserupn].Drive.Root.ItemWithPath("test.txt").Content.Request().PutAsync(stream).Wait();
122 | stream.Close();
123 | Console.WriteLine("\t上传成功");
124 | };
125 |
126 |
127 | }
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | ** Unobtrusive validation support library for jQuery and jQuery Validate
3 | ** Copyright (C) Microsoft Corporation. All rights reserved.
4 | */
5 | !function(a){function e(a,e,n){a.rules[e]=n,a.message&&(a.messages[e]=a.message)}function n(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function t(a){return a.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function r(a){return a.substr(0,a.lastIndexOf(".")+1)}function i(a,e){return 0===a.indexOf("*.")&&(a=a.replace("*.",e)),a}function o(e,n){var r=a(this).find("[data-valmsg-for='"+t(n[0].name)+"']"),i=r.attr("data-valmsg-replace"),o=i?a.parseJSON(i)!==!1:null;r.removeClass("field-validation-valid").addClass("field-validation-error"),e.data("unobtrusiveContainer",r),o?(r.empty(),e.removeClass("input-validation-error").appendTo(r)):e.hide()}function d(e,n){var t=a(this).find("[data-valmsg-summary=true]"),r=t.find("ul");r&&r.length&&n.errorList.length&&(r.empty(),t.addClass("validation-summary-errors").removeClass("validation-summary-valid"),a.each(n.errorList,function(){a(" ").html(this.message).appendTo(r)}))}function s(e){var n=e.data("unobtrusiveContainer");if(n){var t=n.attr("data-valmsg-replace"),r=t?a.parseJSON(t):null;n.addClass("field-validation-valid").removeClass("field-validation-error"),e.removeData("unobtrusiveContainer"),r&&n.empty()}}function l(e){var n=a(this),t="__jquery_unobtrusive_validation_form_reset";if(!n.data(t)){n.data(t,!0);try{n.data("validator").resetForm()}finally{n.removeData(t)}n.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors"),n.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}}function m(e){var n=a(e),t=n.data(v),r=a.proxy(l,e),i=p.unobtrusive.options||{},m=function(n,t){var r=i[n];r&&a.isFunction(r)&&r.apply(e,t)};return t||(t={options:{errorClass:i.errorClass||"input-validation-error",errorElement:i.errorElement||"span",errorPlacement:function(){o.apply(e,arguments),m("errorPlacement",arguments)},invalidHandler:function(){d.apply(e,arguments),m("invalidHandler",arguments)},messages:{},rules:{},success:function(){s.apply(e,arguments),m("success",arguments)}},attachValidation:function(){n.off("reset."+v,r).on("reset."+v,r).validate(this.options)},validate:function(){return n.validate(),n.valid()}},n.data(v,t)),t}var u,p=a.validator,v="unobtrusiveValidation";p.unobtrusive={adapters:[],parseElement:function(e,n){var t,r,i,o=a(e),d=o.parents("form")[0];d&&(t=m(d),t.options.rules[e.name]=r={},t.options.messages[e.name]=i={},a.each(this.adapters,function(){var n="data-val-"+this.name,t=o.attr(n),s={};void 0!==t&&(n+="-",a.each(this.params,function(){s[this]=o.attr(n+this)}),this.adapt({element:e,form:d,message:t,params:s,rules:r,messages:i}))}),a.extend(r,{__dummy__:!0}),n||t.attachValidation())},parse:function(e){var n=a(e),t=n.parents().addBack().filter("form").add(n.find("form")).has("[data-val=true]");n.find("[data-val=true]").each(function(){p.unobtrusive.parseElement(this,!0)}),t.each(function(){var a=m(this);a&&a.attachValidation()})}},u=p.unobtrusive.adapters,u.add=function(a,e,n){return n||(n=e,e=[]),this.push({name:a,params:e,adapt:n}),this},u.addBool=function(a,n){return this.add(a,function(t){e(t,n||a,!0)})},u.addMinMax=function(a,n,t,r,i,o){return this.add(a,[i||"min",o||"max"],function(a){var i=a.params.min,o=a.params.max;i&&o?e(a,r,[i,o]):i?e(a,n,i):o&&e(a,t,o)})},u.addSingleVal=function(a,n,t){return this.add(a,[n||"val"],function(r){e(r,t||a,r.params[n])})},p.addMethod("__dummy__",function(a,e,n){return!0}),p.addMethod("regex",function(a,e,n){var t;return this.optional(e)?!0:(t=new RegExp(n).exec(a),t&&0===t.index&&t[0].length===a.length)}),p.addMethod("nonalphamin",function(a,e,n){var t;return n&&(t=a.match(/\W/g),t=t&&t.length>=n),t}),p.methods.extension?(u.addSingleVal("accept","mimtype"),u.addSingleVal("extension","extension")):u.addSingleVal("extension","extension","accept"),u.addSingleVal("regex","pattern"),u.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"),u.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range"),u.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength"),u.add("equalto",["other"],function(n){var o=r(n.element.name),d=n.params.other,s=i(d,o),l=a(n.form).find(":input").filter("[name='"+t(s)+"']")[0];e(n,"equalTo",l)}),u.add("required",function(a){("INPUT"!==a.element.tagName.toUpperCase()||"CHECKBOX"!==a.element.type.toUpperCase())&&e(a,"required",!0)}),u.add("remote",["url","type","additionalfields"],function(o){var d={url:o.params.url,type:o.params.type||"GET",data:{}},s=r(o.element.name);a.each(n(o.params.additionalfields||o.element.name),function(e,n){var r=i(n,s);d.data[r]=function(){var e=a(o.form).find(":input").filter("[name='"+t(r)+"']");return e.is(":checkbox")?e.filter(":checked").val()||e.filter(":hidden").val()||"":e.is(":radio")?e.filter(":checked").val()||"":e.val()}}),e(o,"remote",d)}),u.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&e(a,"minlength",a.params.min),a.params.nonalphamin&&e(a,"nonalphamin",a.params.nonalphamin),a.params.regex&&e(a,"regex",a.params.regex)}),a(function(){p.unobtrusive.parse(document)})}(jQuery);
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # .NET Core Templates for Office 365 Developer
2 |
3 | English | [简体中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/lang/zh-cn/README.md) | [繁體中文](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/lang/zh-tw/README.md)
4 |
5 | > Author:Ares Chen @ 2018/4/22
6 |
7 | ## Overview
8 |
9 | I wrote an article not long ago [embrace open source, Office 365 development ushered in new age] (https://github.com/chenxizhang/office365dev/blob/master/docs/office365opensource.md), to show you how the typical scenario of Office 365 development supports the open source platform: Use Microsoft Graph, Any development platform can be easily integrated with Office 365; Office Add-ins, SharePoint Add-ins, and Microsoft Teams Apps are developed based on a standard Web development technology stack, and the official default support for mainstream platforms and frameworks such as NodeJS, React, TypeScript, and so on at the tool and template level.
10 |
11 | After the publication of the article, I received quite a lot of feedback. In fact, I am deeply concerned about the vast number of.NET developers. As you know,.NET is completely open - source from head to foot. Is there any templates for Office 365 development scenarios for everyone to use? Using the weekend, I started this new project to organize a standard.NET Core template library for you, and welcome your most familiar position to . You can simply and directly give me `star`, or you can `fork` the project, you can also submit your template through `pull request`, or give me feedback through `issue` channel.
12 |
13 | This set of template libraries will not only reduce the threshold of the vast number of.NET developers (exactly as.NET Core developers) to learn and use the Office 365 development platform (especially how to complete OAuth authentication in different scenarios, and to learn the typical functions of Graph quickly through an instance), and there is a unique value —— You can easily switch between the two instance of Office 365 : the `global` instance and the `gallatin` instance.
14 |
15 | enjoy and happy coding!
16 |
17 | ## The templates
18 |
19 | |Name|Identifier|Short Name|Global|Gallatin|
20 | |:---|:---|:---|:---|:---|
21 | |`Console Application(Graph)`|chenxizhang. dotnetcore. msgraph. console. CSharp|[graphconsole](https://github.com/chenxizhang/dotnetcore-office365dev-templates/blob/master/dotnetcore-graph-console/README.md)|Yes|Yes|
22 | |`Daemon Application(Graph)`|chenxizhang. dotnetcore. msgraph. serviceapp. CSharp|[graphserviceapp](https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-serviceapp/README.md)|Yes|Yes|
23 | |`ASP.NET Web Application(Graph)`|chenxizhang. dotnetcore. msgraph. webapp. CSharp|[graphwebapp](https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-webapp/README.md)|Yes|Yes|
24 | |`ASP.NET MVC Application(Graph)`|chenxizhang. dotnetcore. msgraph. mvcapp. CSharp|[graphmvcapp](https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-mvcapp/README.md)|Yes|Yes|
25 | |`ASP.NET Web API (Graph)`|chenxizhang. dotnetcore. msgraph. mvcapi. CSharp|[graphwebapi](https://github.com/chenxizhang/dotnetcore-office365dev-templates/tree/master/dotnetcore-graph-webapi/README.md)|Yes|Yes|
26 |
27 | ## Prerequisites
28 |
29 | To use these templates, you only need to install.NET Core SDK version 2 or above on the development machine. Please download and install it via the official website ( ), Please note that we are now cross platform, whether Windows, or Mac, or Linux support.NET Core development, while.NET Core applications can be deployed with `docker`, and its development and deployment, operation processes combined with `devops` are also silky.
30 |
31 | In addition, you may need at least one code editor, you can install Visual Studio, or Visual Studio Code, or even any text editor. I use [Visual Studio Code] (http://code.visualstudio.com/).
32 |
33 | ## How to install
34 |
35 | Installing these templates is very simple, you just need a line of commands, `dotnet new -i template-identifier`, for example, using `dotnet new -i chenxizhang.dotnetcore.msgraph.console.CSharp` to install a console application template that can quickly implement Microsoft Graph.
36 |
37 | ## How to use the template
38 |
39 | After the template installation is successful, you can see these new templates in the template list, each template has a short name, you can use the `dotnet new template-shortname` to use these templates, such as `dotnet new graphconsole`, the command can quickly build a Microsoft Graph console application.
40 |
41 | Each template has some parameters to support different scenarios. The most typical parameter is `--instance`. This parameter will tell the template engine which office 365 environment you want to use. There are two options, `global` for the international version, and `gallatin` for the domestic version for China. `gloal` will be the default value for this parameter.
42 |
43 | Actully, you don't need to memorize all these parameters, and you can see the introduction and parameter description of the template through the commands such as `dotnet new template-shortname -h`.
44 |
45 | Each template has a detailed description document. You can click on the shortname of the template in the upper table, and also have a link at the top of the generated code file. I very much welcome you to give me feedback.
46 |
47 | ## How to uninstall the template
48 |
49 | In the following two cases, you may need to uninstall the template.
50 | 1. you don't like these templates anymore.
51 | 1. you need to install the new version of the template
52 |
53 | Whatever the reason, you can simply uninstall through the `dotnet new -u template-identifier` at any time, for example, use `dotnet new -u chenxizhang.dotnetcore.msgraph.console.CSharp` can uninstall the console application template.
54 |
55 | ## FAQ
56 |
57 | 1. What languages do these templates support?
58 | >Currently only C# is supported. Limited to ability and energy, other languages have no support plan for the time being. Welcome friends with other language skills (such as F#, VB.NET, etc.) to participate in the project.
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/Startup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Builder;
6 | using Microsoft.AspNetCore.Hosting;
7 | using Microsoft.Extensions.Configuration;
8 | using Microsoft.Extensions.DependencyInjection;
9 | using Microsoft.AspNetCore.Authentication.Cookies;
10 | using Microsoft.AspNetCore.Authentication.OpenIdConnect;
11 | using Microsoft.Extensions.Logging;
12 | using Microsoft.IdentityModel.Protocols.OpenIdConnect;
13 | using Microsoft.IdentityModel.Tokens;
14 | using Microsoft.IdentityModel.Clients.ActiveDirectory;
15 | using Microsoft.AspNetCore.Http;
16 | using Microsoft.Extensions.Caching.Memory;
17 |
18 | namespace content
19 | {
20 | public class Startup
21 | {
22 |
23 | string clientid, authority, resource, secret, version;
24 | public const string ObjectIdentifierType = "http://schemas.microsoft.com/identity/claims/objectidentifier";
25 | public Startup(IConfiguration configuration)
26 | {
27 | Configuration = configuration;
28 |
29 | #region parameters
30 |
31 | clientid = "{{clientId}}";
32 | secret = "{{secret}}";
33 | version = "{{version}}";
34 |
35 | //#if(instance=="global")
36 | authority = "https://login.microsoftonline.com/common";
37 | resource = "https://graph.microsoft.com";
38 |
39 |
40 | //#else
41 | authority = "https://login.chinacloudapi.cn/common";
42 | resource = "https://microsoftgraph.chinacloudapi.cn";
43 | //#endif
44 | #endregion
45 |
46 | }
47 |
48 | public IConfiguration Configuration { get; }
49 | public const string TenantIdType = "http://schemas.microsoft.com/identity/claims/tenantid";
50 |
51 | // This method gets called by the runtime. Use this method to add services to the container.
52 | public void ConfigureServices(IServiceCollection services)
53 | {
54 | services.AddAuthentication(sharedOptions =>
55 | {
56 | sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
57 | sharedOptions.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
58 | sharedOptions.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
59 | })
60 | .AddOpenIdConnect(options =>
61 | {
62 | options.Authority = authority;
63 | options.Resource = resource;
64 | options.ClientId = clientid;
65 | options.ClientSecret = secret;
66 | options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
67 | options.TokenValidationParameters = new TokenValidationParameters
68 | {
69 | ValidateIssuer = false
70 | };
71 | options.Events = new OpenIdConnectEvents
72 | {
73 | OnTicketReceived = context =>
74 | {
75 | return Task.CompletedTask;
76 | },
77 | OnAuthenticationFailed = async (context) =>
78 | {
79 | await context.Response.WriteAsync("Fail");
80 | },
81 | OnAuthorizationCodeReceived = async (context) =>
82 | {
83 | var code = context.ProtocolMessage.Code;
84 |
85 | var memorycache = context.HttpContext.RequestServices.GetRequiredService();
86 | var identifier = context.Principal.FindFirst(ObjectIdentifierType).Value;
87 | var sessionTokencache = new SessionTokenCache(identifier, memorycache);
88 |
89 | var ctx = new AuthenticationContext(authority, sessionTokencache.GetCacheInstance());
90 | var result = await ctx.AcquireTokenByAuthorizationCodeAsync(code, new Uri("http://localhost:5000/signin-oidc"), new ClientCredential(clientid, secret));
91 | context.HandleCodeRedemption(result.AccessToken, result.IdToken);
92 |
93 | }
94 | };
95 | })
96 | .AddCookie();
97 |
98 | services.AddMvc();
99 |
100 | // This sample uses an in-memory cache for tokens and subscriptions. Production apps will typically use some method of persistent storage.
101 | services.AddMemoryCache();
102 | services.AddSession();
103 |
104 | services.AddSingleton((provider) =>
105 | {
106 | return new GraphSDKHelper(new GraphSettings()
107 | {
108 | Version = version,
109 | ClientId = clientid,
110 | Secret = secret,
111 | Authority = authority,
112 | Resource = resource
113 | });
114 | });
115 | }
116 |
117 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
118 | public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
119 | {
120 | loggerFactory.AddConsole(Configuration.GetSection("Logging"));
121 | loggerFactory.AddDebug();
122 |
123 |
124 |
125 | if (env.IsDevelopment())
126 | {
127 | app.UseDeveloperExceptionPage();
128 | app.UseBrowserLink();
129 | }
130 | else
131 | {
132 | app.UseExceptionHandler("/Home/Error");
133 | }
134 |
135 | app.UseStaticFiles();
136 |
137 | app.UseSession();
138 |
139 | app.UseAuthentication();
140 |
141 | app.UseMvc(routes =>
142 | {
143 | routes.MapRoute(
144 | name: "default",
145 | template: "{controller=Home}/{action=Index}/{id?}");
146 | });
147 | }
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/dotnetcore-graph-mvcapp/content/wwwroot/images/banner2.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------