├── images └── SelectHost.JPG ├── Before ├── Office-Add-in-ASPNET-SSO-WebAPI │ ├── Views │ │ ├── _ViewStart.cshtml │ │ ├── Shared │ │ │ ├── Error.cshtml │ │ │ └── _Layout.cshtml │ │ ├── AzureADAuth │ │ │ ├── Login.cshtml │ │ │ └── Authorize.cshtml │ │ ├── Web.config │ │ └── Home │ │ │ └── Index.cshtml │ ├── favicon.ico │ ├── Global.asax │ ├── Images │ │ ├── Button16x16.png │ │ ├── Button32x32.png │ │ ├── Button80x80.png │ │ └── generic-placeholder.png │ ├── Scripts │ │ ├── _references.js │ │ ├── _officeintellisense.js │ │ ├── Document.js │ │ └── HomeES6.js │ ├── Assets │ │ └── images │ │ │ ├── Button16x16.png │ │ │ ├── Button32x32.png │ │ │ ├── Button80x80.png │ │ │ └── generic-placeholder.png │ ├── Areas │ │ └── HelpPage │ │ │ ├── Views │ │ │ ├── Help │ │ │ │ ├── DisplayTemplates │ │ │ │ │ ├── ImageSample.cshtml │ │ │ │ │ ├── TextSample.cshtml │ │ │ │ │ ├── SimpleTypeModelDescription.cshtml │ │ │ │ │ ├── ComplexTypeModelDescription.cshtml │ │ │ │ │ ├── CollectionModelDescription.cshtml │ │ │ │ │ ├── InvalidSample.cshtml │ │ │ │ │ ├── DictionaryModelDescription.cshtml │ │ │ │ │ ├── KeyValuePairModelDescription.cshtml │ │ │ │ │ ├── EnumTypeModelDescription.cshtml │ │ │ │ │ ├── Samples.cshtml │ │ │ │ │ ├── ModelDescriptionLink.cshtml │ │ │ │ │ ├── ApiGroup.cshtml │ │ │ │ │ ├── Parameters.cshtml │ │ │ │ │ └── HelpPageApiModel.cshtml │ │ │ │ ├── ResourceModel.cshtml │ │ │ │ ├── Api.cshtml │ │ │ │ └── Index.cshtml │ │ │ ├── _ViewStart.cshtml │ │ │ ├── Shared │ │ │ │ └── _Layout.cshtml │ │ │ └── Web.config │ │ │ ├── ModelDescriptions │ │ │ ├── SimpleTypeModelDescription.cs │ │ │ ├── DictionaryModelDescription.cs │ │ │ ├── CollectionModelDescription.cs │ │ │ ├── ParameterAnnotation.cs │ │ │ ├── EnumValueDescription.cs │ │ │ ├── KeyValuePairModelDescription.cs │ │ │ ├── IModelDocumentationProvider.cs │ │ │ ├── ModelDescription.cs │ │ │ ├── ComplexTypeModelDescription.cs │ │ │ ├── EnumTypeModelDescription.cs │ │ │ ├── ParameterDescription.cs │ │ │ ├── ModelNameAttribute.cs │ │ │ └── ModelNameHelper.cs │ │ │ ├── SampleGeneration │ │ │ ├── SampleDirection.cs │ │ │ ├── TextSample.cs │ │ │ ├── InvalidSample.cs │ │ │ └── ImageSample.cs │ │ │ ├── HelpPageAreaRegistration.cs │ │ │ ├── ApiDescriptionExtensions.cs │ │ │ ├── Controllers │ │ │ └── HelpController.cs │ │ │ ├── HelpPage.css │ │ │ └── Models │ │ │ └── HelpPageApiModel.cs │ ├── tsconfig.json │ ├── Startup.cs │ ├── App_Start │ │ ├── FilterConfig.cs │ │ ├── RouteConfig.cs │ │ ├── WebApiConfig.cs │ │ ├── BundleConfig.cs │ │ └── OpenIdConnectCachingSecurityTokenProvider.cs │ ├── Controllers │ │ ├── HomeController.cs │ │ ├── FilesController.cs │ │ ├── ValuesController.cs │ │ └── AzureADAuthController.cs │ ├── Global.asax.cs │ ├── Helpers │ │ ├── HttpErrorHelper.cs │ │ ├── Settings.cs │ │ ├── GraphApiHelper.cs │ │ └── ODataHelper.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Models │ │ └── MSGraphModels.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Content │ │ └── OfficeThemes.css │ └── packages.config ├── Office-Add-in-ASPNET-SSO │ ├── packages.config │ ├── Office-Add-in-ASPNET-SSOManifest │ │ └── SharePointProjectItem.spdata │ └── app.config └── Office-Add-in-ASPNET-SSO.sln ├── Complete ├── Office-Add-in-ASPNET-SSO-WebAPI │ ├── Views │ │ ├── _ViewStart.cshtml │ │ ├── Shared │ │ │ ├── Error.cshtml │ │ │ └── _Layout.cshtml │ │ ├── AzureADAuth │ │ │ ├── Login.cshtml │ │ │ └── Authorize.cshtml │ │ ├── Web.config │ │ └── Home │ │ │ └── Index.cshtml │ ├── Global.asax │ ├── favicon.ico │ ├── Images │ │ ├── Button16x16.png │ │ ├── Button32x32.png │ │ ├── Button80x80.png │ │ └── generic-placeholder.png │ ├── Scripts │ │ ├── _references.js │ │ ├── _officeintellisense.js │ │ └── Document.js │ ├── Areas │ │ └── HelpPage │ │ │ ├── Views │ │ │ ├── Help │ │ │ │ ├── DisplayTemplates │ │ │ │ │ ├── ImageSample.cshtml │ │ │ │ │ ├── TextSample.cshtml │ │ │ │ │ ├── SimpleTypeModelDescription.cshtml │ │ │ │ │ ├── ComplexTypeModelDescription.cshtml │ │ │ │ │ ├── CollectionModelDescription.cshtml │ │ │ │ │ ├── InvalidSample.cshtml │ │ │ │ │ ├── KeyValuePairModelDescription.cshtml │ │ │ │ │ ├── DictionaryModelDescription.cshtml │ │ │ │ │ ├── EnumTypeModelDescription.cshtml │ │ │ │ │ ├── Samples.cshtml │ │ │ │ │ ├── ModelDescriptionLink.cshtml │ │ │ │ │ ├── ApiGroup.cshtml │ │ │ │ │ ├── Parameters.cshtml │ │ │ │ │ └── HelpPageApiModel.cshtml │ │ │ │ ├── ResourceModel.cshtml │ │ │ │ ├── Api.cshtml │ │ │ │ └── Index.cshtml │ │ │ ├── _ViewStart.cshtml │ │ │ ├── Shared │ │ │ │ └── _Layout.cshtml │ │ │ └── Web.config │ │ │ ├── ModelDescriptions │ │ │ ├── SimpleTypeModelDescription.cs │ │ │ ├── DictionaryModelDescription.cs │ │ │ ├── CollectionModelDescription.cs │ │ │ ├── ParameterAnnotation.cs │ │ │ ├── EnumValueDescription.cs │ │ │ ├── KeyValuePairModelDescription.cs │ │ │ ├── IModelDocumentationProvider.cs │ │ │ ├── ModelDescription.cs │ │ │ ├── ComplexTypeModelDescription.cs │ │ │ ├── EnumTypeModelDescription.cs │ │ │ ├── ModelNameAttribute.cs │ │ │ ├── ParameterDescription.cs │ │ │ └── ModelNameHelper.cs │ │ │ ├── SampleGeneration │ │ │ ├── SampleDirection.cs │ │ │ ├── TextSample.cs │ │ │ ├── InvalidSample.cs │ │ │ └── ImageSample.cs │ │ │ ├── HelpPageAreaRegistration.cs │ │ │ ├── ApiDescriptionExtensions.cs │ │ │ ├── Controllers │ │ │ └── HelpController.cs │ │ │ ├── HelpPage.css │ │ │ └── Models │ │ │ └── HelpPageApiModel.cs │ ├── Assets │ │ └── images │ │ │ ├── Button16x16.png │ │ │ ├── Button32x32.png │ │ │ ├── Button80x80.png │ │ │ └── generic-placeholder.png │ ├── tsconfig.json │ ├── App_Start │ │ ├── FilterConfig.cs │ │ ├── RouteConfig.cs │ │ ├── WebApiConfig.cs │ │ ├── BundleConfig.cs │ │ ├── Startup.Auth.cs │ │ └── OpenIdConnectCachingSecurityTokenProvider.cs │ ├── Startup.cs │ ├── Controllers │ │ ├── HomeController.cs │ │ ├── FilesController.cs │ │ ├── AzureADAuthController.cs │ │ └── ValuesController.cs │ ├── Global.asax.cs │ ├── Helpers │ │ ├── HttpErrorHelper.cs │ │ ├── Settings.cs │ │ ├── GraphApiHelper.cs │ │ └── ODataHelper.cs │ ├── Web.Debug.config │ ├── Web.Release.config │ ├── Models │ │ └── MSGraphModels.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Content │ │ └── OfficeThemes.css │ └── packages.config ├── Office-Add-in-ASPNET-SSO │ ├── packages.config │ ├── Office-Add-in-ASPNET-SSOManifest │ │ └── SharePointProjectItem.spdata │ └── app.config └── Office-Add-in-ASPNET-SSO.sln ├── Office-Add-in-ASPNET-SSO.yml └── LICENSE /images/SelectHost.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/images/SelectHost.JPG -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Before/Office-Add-in-ASPNET-SSO-WebAPI/favicon.ico -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="Office_Add_in_ASPNET_SSO_WebAPI.WebApiApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="Office_Add_in_ASPNET_SSO_WebAPI.WebApiApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Complete/Office-Add-in-ASPNET-SSO-WebAPI/favicon.ico -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Images/Button16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Before/Office-Add-in-ASPNET-SSO-WebAPI/Images/Button16x16.png -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Images/Button32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Before/Office-Add-in-ASPNET-SSO-WebAPI/Images/Button32x32.png -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Images/Button80x80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Before/Office-Add-in-ASPNET-SSO-WebAPI/Images/Button80x80.png -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Scripts/_references.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Before/Office-Add-in-ASPNET-SSO-WebAPI/Scripts/_references.js -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Images/Button16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Complete/Office-Add-in-ASPNET-SSO-WebAPI/Images/Button16x16.png -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Images/Button32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Complete/Office-Add-in-ASPNET-SSO-WebAPI/Images/Button32x32.png -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Images/Button80x80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Complete/Office-Add-in-ASPNET-SSO-WebAPI/Images/Button80x80.png -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Scripts/_references.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Complete/Office-Add-in-ASPNET-SSO-WebAPI/Scripts/_references.js -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/Button16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Before/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/Button16x16.png -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/Button32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Before/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/Button32x32.png -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/Button80x80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Before/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/Button80x80.png -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Images/generic-placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Before/Office-Add-in-ASPNET-SSO-WebAPI/Images/generic-placeholder.png -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/ImageSample.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 2 | @model ImageSample 3 | 4 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/ImageSample.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 2 | @model ImageSample 3 | 4 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/Button16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Complete/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/Button16x16.png -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/Button32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Complete/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/Button32x32.png -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/Button80x80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Complete/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/Button80x80.png -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Images/generic-placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Complete/Office-Add-in-ASPNET-SSO-WebAPI/Images/generic-placeholder.png -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/generic-placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Before/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/generic-placeholder.png -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/generic-placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OfficeDev/Office-Add-in-ASPNET-SSO/HEAD/Complete/Office-Add-in-ASPNET-SSO-WebAPI/Assets/images/generic-placeholder.png -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/TextSample.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 2 | @model TextSample 3 | 4 |
5 | @Model.Text
6 | 
-------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/TextSample.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 2 | @model TextSample 3 | 4 |
5 | @Model.Text
6 | 
-------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/SimpleTypeModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model SimpleTypeModelDescription 3 | @Model.Documentation -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/SimpleTypeModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model SimpleTypeModelDescription 3 | @Model.Documentation -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | // Change the Layout path below to blend the look and feel of the help page with your existing web pages. 3 | Layout = "~/Areas/HelpPage/Views/Shared/_Layout.cshtml"; 4 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | // Change the Layout path below to blend the look and feel of the help page with your existing web pages. 3 | Layout = "~/Areas/HelpPage/Views/Shared/_Layout.cshtml"; 4 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/SimpleTypeModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class SimpleTypeModelDescription : ModelDescription 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/SimpleTypeModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class SimpleTypeModelDescription : ModelDescription 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/ComplexTypeModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model ComplexTypeModelDescription 3 | @Html.DisplayFor(m => m.Properties, "Parameters") -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/ComplexTypeModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model ComplexTypeModelDescription 3 | @Html.DisplayFor(m => m.Properties, "Parameters") -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/DictionaryModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class DictionaryModelDescription : KeyValuePairModelDescription 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/DictionaryModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class DictionaryModelDescription : KeyValuePairModelDescription 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": true, 3 | "compilerOptions": { 4 | "sourceMap": true, 5 | "allowJs": true, 6 | "target": "es5", 7 | "outFile": "Scripts/Home.js" 8 | }, 9 | "files": [ 10 | "Scripts/HomeES6.js" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": true, 3 | "compilerOptions": { 4 | "sourceMap": true, 5 | "allowJs": true, 6 | "target": "es5", 7 | "outFile": "Scripts/Home.js" 8 | }, 9 | "files": [ 10 | "Scripts/HomeES6.js" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/CollectionModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class CollectionModelDescription : ModelDescription 4 | { 5 | public ModelDescription ElementDescription { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/CollectionModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class CollectionModelDescription : ModelDescription 4 | { 5 | public ModelDescription ElementDescription { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/CollectionModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model CollectionModelDescription 3 | @if (Model.ElementDescription is ComplexTypeModelDescription) 4 | { 5 | @Html.DisplayFor(m => m.ElementDescription) 6 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Microsoft.Owin; 4 | using Owin; 5 | 6 | [assembly: OwinStartup(typeof(Office_Add_in_ASPNET_SSO_WebAPI.Startup))] 7 | 8 | namespace Office_Add_in_ASPNET_SSO_WebAPI 9 | { 10 | public partial class Startup 11 | { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/CollectionModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model CollectionModelDescription 3 | @if (Model.ElementDescription is ComplexTypeModelDescription) 4 | { 5 | @Html.DisplayFor(m => m.ElementDescription) 6 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/SampleGeneration/SampleDirection.cs: -------------------------------------------------------------------------------- 1 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 2 | { 3 | /// 4 | /// Indicates whether the sample is used for request or response 5 | /// 6 | public enum SampleDirection 7 | { 8 | Request = 0, 9 | Response 10 | } 11 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | @ViewBag.Title 7 | @RenderSection("scripts", required: false) 8 | 9 | 10 | @RenderBody() 11 | 12 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Error 6 | 7 | 8 |
9 |

Error.

10 |

An error occurred while processing your request.

11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/SampleGeneration/SampleDirection.cs: -------------------------------------------------------------------------------- 1 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 2 | { 3 | /// 4 | /// Indicates whether the sample is used for request or response 5 | /// 6 | public enum SampleDirection 7 | { 8 | Request = 0, 9 | Response 10 | } 11 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Error 6 | 7 | 8 |
9 |

Error.

10 |

An error occurred while processing your request.

11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/ParameterAnnotation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 4 | { 5 | public class ParameterAnnotation 6 | { 7 | public Attribute AnnotationAttribute { get; set; } 8 | 9 | public string Documentation { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | @ViewBag.Title 7 | @RenderSection("scripts", required: false) 8 | 9 | 10 | @RenderBody() 11 | 12 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/ParameterAnnotation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 4 | { 5 | public class ParameterAnnotation 6 | { 7 | public Attribute AnnotationAttribute { get; set; } 8 | 9 | public string Documentation { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace Office_Add_in_ASPNET_SSO_WebAPI 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/EnumValueDescription.cs: -------------------------------------------------------------------------------- 1 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class EnumValueDescription 4 | { 5 | public string Documentation { get; set; } 6 | 7 | public string Name { get; set; } 8 | 9 | public string Value { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/EnumValueDescription.cs: -------------------------------------------------------------------------------- 1 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class EnumValueDescription 4 | { 5 | public string Documentation { get; set; } 6 | 7 | public string Name { get; set; } 8 | 9 | public string Value { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using System.Web.Mvc; 3 | 4 | namespace Office_Add_in_ASPNET_SSO_WebAPI 5 | { 6 | public class FilterConfig 7 | { 8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 9 | { 10 | filters.Add(new HandleErrorAttribute()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/InvalidSample.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 2 | @model InvalidSample 3 | 4 | @if (HttpContext.Current.IsDebuggingEnabled) 5 | { 6 |
7 |

@Model.ErrorMessage

8 |
9 | } 10 | else 11 | { 12 |

Sample not available.

13 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/InvalidSample.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 2 | @model InvalidSample 3 | 4 | @if (HttpContext.Current.IsDebuggingEnabled) 5 | { 6 |
7 |

@Model.ErrorMessage

8 |
9 | } 10 | else 11 | { 12 |

Sample not available.

13 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/KeyValuePairModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class KeyValuePairModelDescription : ModelDescription 4 | { 5 | public ModelDescription KeyModelDescription { get; set; } 6 | 7 | public ModelDescription ValueModelDescription { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/KeyValuePairModelDescription.cs: -------------------------------------------------------------------------------- 1 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | { 3 | public class KeyValuePairModelDescription : ModelDescription 4 | { 5 | public ModelDescription KeyModelDescription { get; set; } 6 | 7 | public ModelDescription ValueModelDescription { get; set; } 8 | } 9 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/IModelDocumentationProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 5 | { 6 | public interface IModelDocumentationProvider 7 | { 8 | string GetDocumentation(MemberInfo member); 9 | 10 | string GetDocumentation(Type type); 11 | } 12 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/IModelDocumentationProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 5 | { 6 | public interface IModelDocumentationProvider 7 | { 8 | string GetDocumentation(MemberInfo member); 9 | 10 | string GetDocumentation(Type type); 11 | } 12 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Microsoft.Owin; 4 | using Owin; 5 | 6 | [assembly: OwinStartup(typeof(Office_Add_in_ASPNET_SSO_WebAPI.Startup))] 7 | 8 | namespace Office_Add_in_ASPNET_SSO_WebAPI 9 | { 10 | public partial class Startup 11 | { 12 | public void Configuration(IAppBuilder app) 13 | { 14 | ConfigureAuth(app); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Views/AzureADAuth/Login.cshtml: -------------------------------------------------------------------------------- 1 | @*Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo.*@ 2 | 3 | @* 4 | This page is only seen if the web.config has an empty string for either the app's ID or its secret. 5 | *@ 6 | 7 | 8 | @model dynamic 9 | 10 | @{ 11 | ViewBag.Title = "Login Error"; 12 | 13 | } 14 | 15 |

Login Error

16 | 17 |

@ViewBag.Message

18 | 19 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Views/AzureADAuth/Login.cshtml: -------------------------------------------------------------------------------- 1 | @*Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo.*@ 2 | 3 | @* 4 | This page is only seen if the web.config has an empty string for either the app's ID or its secret. 5 | *@ 6 | 7 | 8 | @model dynamic 9 | 10 | @{ 11 | ViewBag.Title = "Login Error"; 12 | 13 | } 14 | 15 |

Login Error

16 | 17 |

@ViewBag.Message

18 | 19 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/ModelDescription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 4 | { 5 | /// 6 | /// Describes a type model. 7 | /// 8 | public abstract class ModelDescription 9 | { 10 | public string Documentation { get; set; } 11 | 12 | public Type ModelType { get; set; } 13 | 14 | public string Name { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/ModelDescription.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 4 | { 5 | /// 6 | /// Describes a type model. 7 | /// 8 | public abstract class ModelDescription 9 | { 10 | public string Documentation { get; set; } 11 | 12 | public Type ModelType { get; set; } 13 | 14 | public string Name { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/DictionaryModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model DictionaryModelDescription 3 | Dictionary of @Html.DisplayFor(m => Model.KeyModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.KeyModelDescription }) [key] 4 | and @Html.DisplayFor(m => Model.ValueModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ValueModelDescription }) [value] -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/KeyValuePairModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model KeyValuePairModelDescription 3 | Pair of @Html.DisplayFor(m => Model.KeyModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.KeyModelDescription }) [key] 4 | and @Html.DisplayFor(m => Model.ValueModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ValueModelDescription }) [value] -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/KeyValuePairModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model KeyValuePairModelDescription 3 | Pair of @Html.DisplayFor(m => Model.KeyModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.KeyModelDescription }) [key] 4 | and @Html.DisplayFor(m => Model.ValueModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ValueModelDescription }) [value] -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/DictionaryModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model DictionaryModelDescription 3 | Dictionary of @Html.DisplayFor(m => Model.KeyModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.KeyModelDescription }) [key] 4 | and @Html.DisplayFor(m => Model.ValueModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ValueModelDescription }) [value] -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/ComplexTypeModelDescription.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 4 | { 5 | public class ComplexTypeModelDescription : ModelDescription 6 | { 7 | public ComplexTypeModelDescription() 8 | { 9 | Properties = new Collection(); 10 | } 11 | 12 | public Collection Properties { get; private set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/ComplexTypeModelDescription.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 4 | { 5 | public class ComplexTypeModelDescription : ModelDescription 6 | { 7 | public ComplexTypeModelDescription() 8 | { 9 | Properties = new Collection(); 10 | } 11 | 12 | public Collection Properties { get; private set; } 13 | } 14 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/EnumTypeModelDescription.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 5 | { 6 | public class EnumTypeModelDescription : ModelDescription 7 | { 8 | public EnumTypeModelDescription() 9 | { 10 | Values = new Collection(); 11 | } 12 | 13 | public Collection Values { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/EnumTypeModelDescription.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 5 | { 6 | public class EnumTypeModelDescription : ModelDescription 7 | { 8 | public EnumTypeModelDescription() 9 | { 10 | Values = new Collection(); 11 | } 12 | 13 | public Collection Values { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO/Office-Add-in-ASPNET-SSOManifest/SharePointProjectItem.spdata: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO/Office-Add-in-ASPNET-SSOManifest/SharePointProjectItem.spdata: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the root of the repo. 2 | 3 | /* 4 | This file provides the controller method that shows the home page. 5 | */ 6 | 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Linq; 10 | using System.Web; 11 | using System.Web.Mvc; 12 | 13 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Controllers 14 | { 15 | public class HomeController : Controller 16 | { 17 | public ActionResult Index() 18 | { 19 | ViewBag.Title = "Home Page"; 20 | 21 | return View(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the root of the repo. 2 | 3 | /* 4 | This file provides the controller method that shows the home page. 5 | */ 6 | 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Linq; 10 | using System.Web; 11 | using System.Web.Mvc; 12 | 13 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Controllers 14 | { 15 | public class HomeController : Controller 16 | { 17 | public ActionResult Index() 18 | { 19 | ViewBag.Title = "Home Page"; 20 | 21 | return View(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/ParameterDescription.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 5 | { 6 | public class ParameterDescription 7 | { 8 | public ParameterDescription() 9 | { 10 | Annotations = new Collection(); 11 | } 12 | 13 | public Collection Annotations { get; private set; } 14 | 15 | public string Documentation { get; set; } 16 | 17 | public string Name { get; set; } 18 | 19 | public ModelDescription TypeDescription { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/ModelNameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 4 | { 5 | /// 6 | /// Use this attribute to change the name of the generated for a type. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum, AllowMultiple = false, Inherited = false)] 9 | public sealed class ModelNameAttribute : Attribute 10 | { 11 | public ModelNameAttribute(string name) 12 | { 13 | Name = name; 14 | } 15 | 16 | public string Name { get; private set; } 17 | } 18 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/ModelNameAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 4 | { 5 | /// 6 | /// Use this attribute to change the name of the generated for a type. 7 | /// 8 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum, AllowMultiple = false, Inherited = false)] 9 | public sealed class ModelNameAttribute : Attribute 10 | { 11 | public ModelNameAttribute(string name) 12 | { 13 | Name = name; 14 | } 15 | 16 | public string Name { get; private set; } 17 | } 18 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/ParameterDescription.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | 4 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 5 | { 6 | public class ParameterDescription 7 | { 8 | public ParameterDescription() 9 | { 10 | Annotations = new Collection(); 11 | } 12 | 13 | public Collection Annotations { get; private set; } 14 | 15 | public string Documentation { get; set; } 16 | 17 | public string Name { get; set; } 18 | 19 | public ModelDescription TypeDescription { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace Office_Add_in_ASPNET_SSO_WebAPI 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/ResourceModel.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 3 | @model ModelDescription 4 | 5 | 6 |
7 | 14 |

@Model.Name

15 |

@Model.Documentation

16 |
17 | @Html.DisplayFor(m => Model) 18 |
19 |
20 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Mvc; 6 | using System.Web.Routing; 7 | 8 | namespace Office_Add_in_ASPNET_SSO_WebAPI 9 | { 10 | public class RouteConfig 11 | { 12 | public static void RegisterRoutes(RouteCollection routes) 13 | { 14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 15 | 16 | routes.MapRoute( 17 | name: "Default", 18 | url: "{controller}/{action}/{id}", 19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 20 | ); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/ResourceModel.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 3 | @model ModelDescription 4 | 5 | 6 |
7 | 14 |

@Model.Name

15 |

@Model.Documentation

16 |
17 | @Html.DisplayFor(m => Model) 18 |
19 |
20 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web.Http; 5 | 6 | namespace Office_Add_in_ASPNET_SSO_WebAPI 7 | { 8 | public static class WebApiConfig 9 | { 10 | public static void Register(HttpConfiguration config) 11 | { 12 | // Web API configuration and services 13 | 14 | // Web API routes 15 | config.MapHttpAttributeRoutes(); 16 | 17 | config.Routes.MapHttpRoute( 18 | name: "DefaultApi", 19 | routeTemplate: "api/{controller}/{id}", 20 | defaults: new { id = RouteParameter.Optional } 21 | ); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/App_Start/WebApiConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web.Http; 5 | 6 | namespace Office_Add_in_ASPNET_SSO_WebAPI 7 | { 8 | public static class WebApiConfig 9 | { 10 | public static void Register(HttpConfiguration config) 11 | { 12 | // Web API configuration and services 13 | 14 | // Web API routes 15 | config.MapHttpAttributeRoutes(); 16 | 17 | config.Routes.MapHttpRoute( 18 | name: "DefaultApi", 19 | routeTemplate: "api/{controller}/{id}", 20 | defaults: new { id = RouteParameter.Optional } 21 | ); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Http; 6 | using System.Web.Mvc; 7 | using System.Web.Optimization; 8 | using System.Web.Routing; 9 | 10 | namespace Office_Add_in_ASPNET_SSO_WebAPI 11 | { 12 | public class WebApiApplication : System.Web.HttpApplication 13 | { 14 | protected void Application_Start() 15 | { 16 | GlobalConfiguration.Configure(WebApiConfig.Register); 17 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 18 | RouteConfig.RegisterRoutes(RouteTable.Routes); 19 | BundleConfig.RegisterBundles(BundleTable.Bundles); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web; 5 | using System.Web.Http; 6 | using System.Web.Mvc; 7 | using System.Web.Optimization; 8 | using System.Web.Routing; 9 | 10 | namespace Office_Add_in_ASPNET_SSO_WebAPI 11 | { 12 | public class WebApiApplication : System.Web.HttpApplication 13 | { 14 | protected void Application_Start() 15 | { 16 | GlobalConfiguration.Configure(WebApiConfig.Register); 17 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 18 | RouteConfig.RegisterRoutes(RouteTable.Routes); 19 | BundleConfig.RegisterBundles(BundleTable.Bundles); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Controllers/FilesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.Http; 6 | using System.Web.Http; 7 | using System.Threading.Tasks; 8 | using Office_Add_in_ASPNET_SSO_WebAPI.Helpers; 9 | using Office_Add_in_ASPNET_SSO_WebAPI.Models; 10 | 11 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Controllers 12 | { 13 | public class FilesController : ApiController 14 | { 15 | 16 | // GET api/files 17 | public async Task Get() 18 | { 19 | string accessToken = Request.Headers.Authorization.ToString().Split(' ')[1]; 20 | 21 | return await GraphApiHelper.GetOneDriveFileNames(accessToken); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Controllers/FilesController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.Http; 6 | using System.Web.Http; 7 | using System.Threading.Tasks; 8 | using Office_Add_in_ASPNET_SSO_WebAPI.Helpers; 9 | using Office_Add_in_ASPNET_SSO_WebAPI.Models; 10 | 11 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Controllers 12 | { 13 | public class FilesController : ApiController 14 | { 15 | 16 | // GET api/files 17 | public async Task Get() 18 | { 19 | string accessToken = Request.Headers.Authorization.ToString().Split(' ')[1]; 20 | 21 | return await GraphApiHelper.GetOneDriveFileNames(accessToken); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/Api.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Models 3 | @model HelpPageApiModel 4 | 5 | @{ 6 | var description = Model.ApiDescription; 7 | ViewBag.Title = description.HttpMethod.Method + " " + description.RelativePath; 8 | } 9 | 10 | 11 |
12 | 19 |
20 | @Html.DisplayForModel() 21 |
22 |
23 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/Api.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Models 3 | @model HelpPageApiModel 4 | 5 | @{ 6 | var description = Model.ApiDescription; 7 | ViewBag.Title = description.HttpMethod.Method + " " + description.RelativePath; 8 | } 9 | 10 | 11 |
12 | 19 |
20 | @Html.DisplayForModel() 21 |
22 |
23 | -------------------------------------------------------------------------------- /Office-Add-in-ASPNET-SSO.yml: -------------------------------------------------------------------------------- 1 | ### YamlMime:Sample 2 | sample: 3 | - name: Office Add-in that that supports Single Sign-on to Office, the Add-in, and Microsoft Graph 4 | path: '' 5 | description: The getAccessTokenAsync API in Office.js enables users who are signed into Office to get access to an AAD-protected add-in and to Microsoft Graph without needing to sign-in again. This sample is built on ASP.NET and Microsoft Identity Library (MSAL). 6 | readme: '' 7 | generateZip: FALSE 8 | isLive: TRUE 9 | technologies: 10 | - Office Add-in 11 | - Microsoft Graph 12 | azureDeploy: '' 13 | author: rick-kirkham 14 | platforms: [] 15 | languages: 16 | - JavaScript 17 | - ASP.NET 18 | extensions: 19 | products: 20 | - Excel 21 | - PowerPoint 22 | - Word 23 | scenarios: [] 24 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/HelpPageAreaRegistration.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Http; 2 | using System.Web.Mvc; 3 | 4 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 5 | { 6 | public class HelpPageAreaRegistration : AreaRegistration 7 | { 8 | public override string AreaName 9 | { 10 | get 11 | { 12 | return "HelpPage"; 13 | } 14 | } 15 | 16 | public override void RegisterArea(AreaRegistrationContext context) 17 | { 18 | context.MapRoute( 19 | "HelpPage_Default", 20 | "Help/{action}/{apiId}", 21 | new { controller = "Help", action = "Index", apiId = UrlParameter.Optional }); 22 | 23 | HelpPageConfig.Register(GlobalConfiguration.Configuration); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/HelpPageAreaRegistration.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Http; 2 | using System.Web.Mvc; 3 | 4 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 5 | { 6 | public class HelpPageAreaRegistration : AreaRegistration 7 | { 8 | public override string AreaName 9 | { 10 | get 11 | { 12 | return "HelpPage"; 13 | } 14 | } 15 | 16 | public override void RegisterArea(AreaRegistrationContext context) 17 | { 18 | context.MapRoute( 19 | "HelpPage_Default", 20 | "Help/{action}/{apiId}", 21 | new { controller = "Help", action = "Index", apiId = UrlParameter.Optional }); 22 | 23 | HelpPageConfig.Register(GlobalConfiguration.Configuration); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo. 2 | using System.Web.Optimization; 3 | 4 | namespace Office_Add_in_ASPNET_SSO_WebAPI 5 | { 6 | public class BundleConfig 7 | { 8 | // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 9 | public static void RegisterBundles(BundleCollection bundles) 10 | { 11 | bundles.Add(new StyleBundle("~/Content/css").Include( 12 | "~/Content/Site.css")); 13 | 14 | bundles.Add(new ScriptBundle("~/bundles/OfficeAddinMicrosoftGraphASPNET") 15 | .Include("~/Scripts/Home.js") 16 | .Include("~/Scripts/Document.js") 17 | ); 18 | 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Helpers/HttpErrorHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Net.Http; 4 | using System.Web.Http; 5 | 6 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Helpers 7 | { 8 | internal static class HttpErrorHelper 9 | { 10 | internal static HttpResponseMessage SendErrorToClient(HttpStatusCode statusCode, Exception e, string message) 11 | { 12 | HttpError error; 13 | if (e != null) 14 | { 15 | error = new HttpError(e, true); 16 | } 17 | else 18 | { 19 | error = new HttpError(message); 20 | } 21 | var requestMessage = new HttpRequestMessage(); 22 | var errorMessage = requestMessage.CreateErrorResponse(statusCode, error); 23 | return errorMessage; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo. 2 | using System.Web.Optimization; 3 | 4 | namespace Office_Add_in_ASPNET_SSO_WebAPI 5 | { 6 | public class BundleConfig 7 | { 8 | // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 9 | public static void RegisterBundles(BundleCollection bundles) 10 | { 11 | bundles.Add(new StyleBundle("~/Content/css").Include( 12 | "~/Content/Site.css")); 13 | 14 | bundles.Add(new ScriptBundle("~/bundles/OfficeAddinMicrosoftGraphASPNET") 15 | .Include("~/Scripts/Home.js") 16 | .Include("~/Scripts/Document.js") 17 | ); 18 | 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/EnumTypeModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model EnumTypeModelDescription 3 | 4 |

Possible enumeration values:

5 | 6 | 7 | 8 | 9 | 10 | 11 | @foreach (EnumValueDescription value in Model.Values) 12 | { 13 | 14 | 15 | 18 | 21 | 22 | } 23 | 24 |
NameValueDescription
@value.Name 16 |

@value.Value

17 |
19 |

@value.Documentation

20 |
-------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Helpers/HttpErrorHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Net.Http; 4 | using System.Web.Http; 5 | 6 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Helpers 7 | { 8 | internal static class HttpErrorHelper 9 | { 10 | internal static HttpResponseMessage SendErrorToClient(HttpStatusCode statusCode, Exception e, string message) 11 | { 12 | HttpError error; 13 | if (e != null) 14 | { 15 | error = new HttpError(e, true); 16 | } 17 | else 18 | { 19 | error = new HttpError(message); 20 | } 21 | var requestMessage = new HttpRequestMessage(); 22 | var errorMessage = requestMessage.CreateErrorResponse(statusCode, error); 23 | return errorMessage; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/EnumTypeModelDescription.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model EnumTypeModelDescription 3 | 4 |

Possible enumeration values:

5 | 6 | 7 | 8 | 9 | 10 | 11 | @foreach (EnumValueDescription value in Model.Values) 12 | { 13 | 14 | 15 | 18 | 21 | 22 | } 23 | 24 |
NameValueDescription
@value.Name 16 |

@value.Value

17 |
19 |

@value.Documentation

20 |
-------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Views/AzureADAuth/Authorize.cshtml: -------------------------------------------------------------------------------- 1 | @*Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo.*@ 2 | 3 | @{ 4 | ViewBag.Title = "Authorize"; 5 | } 6 | 7 | 8 | 9 | 24 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Views/AzureADAuth/Authorize.cshtml: -------------------------------------------------------------------------------- 1 | @*Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo.*@ 2 | 3 | @{ 4 | ViewBag.Title = "Authorize"; 5 | } 6 | 7 | 8 | 9 | 24 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Helpers/Settings.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo. 2 | using System; 3 | using System.Configuration; 4 | using System.Web; 5 | 6 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Helpers 7 | { 8 | /// 9 | /// Provides management of basic user and web application authentication and authorization information. 10 | /// 11 | public static class Settings 12 | { 13 | public static string AzureADAuthority = ConfigurationManager.AppSettings["ida:Authority"]; 14 | public static string AzureADClientId = ConfigurationManager.AppSettings["ida:ClientID"]; 15 | public static string AzureADClientSecret = ConfigurationManager.AppSettings["ida:Password"]; 16 | //public static string AzureADLogoutAuthority = @"https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri="; 17 | public static string GraphApiResource = @"https://graph.microsoft.com/"; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Helpers/Settings.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo. 2 | using System; 3 | using System.Configuration; 4 | using System.Web; 5 | 6 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Helpers 7 | { 8 | /// 9 | /// Provides management of basic user and web application authentication and authorization information. 10 | /// 11 | public static class Settings 12 | { 13 | public static string AzureADAuthority = ConfigurationManager.AppSettings["ida:Authority"]; 14 | public static string AzureADClientId = ConfigurationManager.AppSettings["ida:ClientID"]; 15 | public static string AzureADClientSecret = ConfigurationManager.AppSettings["ida:Password"]; 16 | //public static string AzureADLogoutAuthority = @"https://login.microsoftonline.com/common/oauth2/logout?post_logout_redirect_uri="; 17 | public static string GraphApiResource = @"https://graph.microsoft.com/"; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/Samples.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Net.Http.Headers 2 | @model Dictionary 3 | 4 | @{ 5 | // Group the samples into a single tab if they are the same. 6 | Dictionary samples = Model.GroupBy(pair => pair.Value).ToDictionary( 7 | pair => String.Join(", ", pair.Select(m => m.Key.ToString()).ToArray()), 8 | pair => pair.Key); 9 | var mediaTypes = samples.Keys; 10 | } 11 |
12 | @foreach (var mediaType in mediaTypes) 13 | { 14 |

@mediaType

15 |
16 | Sample: 17 | @{ 18 | var sample = samples[mediaType]; 19 | if (sample == null) 20 | { 21 |

Sample not available.

22 | } 23 | else 24 | { 25 | @Html.DisplayFor(s => sample); 26 | } 27 | } 28 |
29 | } 30 |
-------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/Samples.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Net.Http.Headers 2 | @model Dictionary 3 | 4 | @{ 5 | // Group the samples into a single tab if they are the same. 6 | Dictionary samples = Model.GroupBy(pair => pair.Value).ToDictionary( 7 | pair => String.Join(", ", pair.Select(m => m.Key.ToString()).ToArray()), 8 | pair => pair.Key); 9 | var mediaTypes = samples.Keys; 10 | } 11 |
12 | @foreach (var mediaType in mediaTypes) 13 | { 14 |

@mediaType

15 |
16 | Sample: 17 | @{ 18 | var sample = samples[mediaType]; 19 | if (sample == null) 20 | { 21 |

Sample not available.

22 | } 23 | else 24 | { 25 | @Html.DisplayFor(s => sample); 26 | } 27 | } 28 |
29 | } 30 |
-------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/SampleGeneration/TextSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 4 | { 5 | /// 6 | /// This represents a preformatted text sample on the help page. There's a display template named TextSample associated with this class. 7 | /// 8 | public class TextSample 9 | { 10 | public TextSample(string text) 11 | { 12 | if (text == null) 13 | { 14 | throw new ArgumentNullException("text"); 15 | } 16 | Text = text; 17 | } 18 | 19 | public string Text { get; private set; } 20 | 21 | public override bool Equals(object obj) 22 | { 23 | TextSample other = obj as TextSample; 24 | return other != null && Text == other.Text; 25 | } 26 | 27 | public override int GetHashCode() 28 | { 29 | return Text.GetHashCode(); 30 | } 31 | 32 | public override string ToString() 33 | { 34 | return Text; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/SampleGeneration/TextSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 4 | { 5 | /// 6 | /// This represents a preformatted text sample on the help page. There's a display template named TextSample associated with this class. 7 | /// 8 | public class TextSample 9 | { 10 | public TextSample(string text) 11 | { 12 | if (text == null) 13 | { 14 | throw new ArgumentNullException("text"); 15 | } 16 | Text = text; 17 | } 18 | 19 | public string Text { get; private set; } 20 | 21 | public override bool Equals(object obj) 22 | { 23 | TextSample other = obj as TextSample; 24 | return other != null && Text == other.Text; 25 | } 26 | 27 | public override int GetHashCode() 28 | { 29 | return Text.GetHashCode(); 30 | } 31 | 32 | public override string ToString() 33 | { 34 | return Text; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/ModelDescriptionLink.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model Type 3 | @{ 4 | ModelDescription modelDescription = ViewBag.modelDescription; 5 | if (modelDescription is ComplexTypeModelDescription || modelDescription is EnumTypeModelDescription) 6 | { 7 | if (Model == typeof(Object)) 8 | { 9 | @:Object 10 | } 11 | else 12 | { 13 | @Html.ActionLink(modelDescription.Name, "ResourceModel", "Help", new { modelName = modelDescription.Name }, null) 14 | } 15 | } 16 | else if (modelDescription is CollectionModelDescription) 17 | { 18 | var collectionDescription = modelDescription as CollectionModelDescription; 19 | var elementDescription = collectionDescription.ElementDescription; 20 | @:Collection of @Html.DisplayFor(m => elementDescription.ModelType, "ModelDescriptionLink", new { modelDescription = elementDescription }) 21 | } 22 | else 23 | { 24 | @Html.DisplayFor(m => modelDescription) 25 | } 26 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/ModelDescriptionLink.cshtml: -------------------------------------------------------------------------------- 1 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 2 | @model Type 3 | @{ 4 | ModelDescription modelDescription = ViewBag.modelDescription; 5 | if (modelDescription is ComplexTypeModelDescription || modelDescription is EnumTypeModelDescription) 6 | { 7 | if (Model == typeof(Object)) 8 | { 9 | @:Object 10 | } 11 | else 12 | { 13 | @Html.ActionLink(modelDescription.Name, "ResourceModel", "Help", new { modelName = modelDescription.Name }, null) 14 | } 15 | } 16 | else if (modelDescription is CollectionModelDescription) 17 | { 18 | var collectionDescription = modelDescription as CollectionModelDescription; 19 | var elementDescription = collectionDescription.ElementDescription; 20 | @:Collection of @Html.DisplayFor(m => elementDescription.ModelType, "ModelDescriptionLink", new { modelDescription = elementDescription }) 21 | } 22 | else 23 | { 24 | @Html.DisplayFor(m => modelDescription) 25 | } 26 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/SampleGeneration/InvalidSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 4 | { 5 | /// 6 | /// This represents an invalid sample on the help page. There's a display template named InvalidSample associated with this class. 7 | /// 8 | public class InvalidSample 9 | { 10 | public InvalidSample(string errorMessage) 11 | { 12 | if (errorMessage == null) 13 | { 14 | throw new ArgumentNullException("errorMessage"); 15 | } 16 | ErrorMessage = errorMessage; 17 | } 18 | 19 | public string ErrorMessage { get; private set; } 20 | 21 | public override bool Equals(object obj) 22 | { 23 | InvalidSample other = obj as InvalidSample; 24 | return other != null && ErrorMessage == other.ErrorMessage; 25 | } 26 | 27 | public override int GetHashCode() 28 | { 29 | return ErrorMessage.GetHashCode(); 30 | } 31 | 32 | public override string ToString() 33 | { 34 | return ErrorMessage; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/SampleGeneration/InvalidSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 4 | { 5 | /// 6 | /// This represents an invalid sample on the help page. There's a display template named InvalidSample associated with this class. 7 | /// 8 | public class InvalidSample 9 | { 10 | public InvalidSample(string errorMessage) 11 | { 12 | if (errorMessage == null) 13 | { 14 | throw new ArgumentNullException("errorMessage"); 15 | } 16 | ErrorMessage = errorMessage; 17 | } 18 | 19 | public string ErrorMessage { get; private set; } 20 | 21 | public override bool Equals(object obj) 22 | { 23 | InvalidSample other = obj as InvalidSample; 24 | return other != null && ErrorMessage == other.ErrorMessage; 25 | } 26 | 27 | public override int GetHashCode() 28 | { 29 | return ErrorMessage.GetHashCode(); 30 | } 31 | 32 | public override string ToString() 33 | { 34 | return ErrorMessage; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Office Add-in ASP.NET SSO 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | MIT License 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files (the 9 | "Software"), to deal in the Software without restriction, including 10 | without limitation the rights to use, copy, modify, merge, publish, 11 | distribute, sublicense, and/or sell copies of the Software, and to 12 | permit persons to whom the Software is furnished to do so, subject to 13 | the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/SampleGeneration/ImageSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 4 | { 5 | /// 6 | /// This represents an image sample on the help page. There's a display template named ImageSample associated with this class. 7 | /// 8 | public class ImageSample 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | /// The URL of an image. 14 | public ImageSample(string src) 15 | { 16 | if (src == null) 17 | { 18 | throw new ArgumentNullException("src"); 19 | } 20 | Src = src; 21 | } 22 | 23 | public string Src { get; private set; } 24 | 25 | public override bool Equals(object obj) 26 | { 27 | ImageSample other = obj as ImageSample; 28 | return other != null && Src == other.Src; 29 | } 30 | 31 | public override int GetHashCode() 32 | { 33 | return Src.GetHashCode(); 34 | } 35 | 36 | public override string ToString() 37 | { 38 | return Src; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/SampleGeneration/ImageSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 4 | { 5 | /// 6 | /// This represents an image sample on the help page. There's a display template named ImageSample associated with this class. 7 | /// 8 | public class ImageSample 9 | { 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | /// The URL of an image. 14 | public ImageSample(string src) 15 | { 16 | if (src == null) 17 | { 18 | throw new ArgumentNullException("src"); 19 | } 20 | Src = src; 21 | } 22 | 23 | public string Src { get; private set; } 24 | 25 | public override bool Equals(object obj) 26 | { 27 | ImageSample other = obj as ImageSample; 28 | return other != null && Src == other.Src; 29 | } 30 | 31 | public override int GetHashCode() 32 | { 33 | return Src.GetHashCode(); 34 | } 35 | 36 | public override string ToString() 37 | { 38 | return Src; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/Index.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using System.Web.Http.Controllers 3 | @using System.Web.Http.Description 4 | @using System.Collections.ObjectModel 5 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Models 6 | @model Collection 7 | 8 | @{ 9 | ViewBag.Title = "ASP.NET Web API Help Page"; 10 | 11 | // Group APIs by controller 12 | ILookup apiGroups = Model.ToLookup(api => api.ActionDescriptor.ControllerDescriptor); 13 | } 14 | 15 | 16 |
17 |
18 |
19 |

@ViewBag.Title

20 |
21 |
22 |
23 |
24 | 32 |
33 | @foreach (var group in apiGroups) 34 | { 35 | @Html.DisplayFor(m => group, "ApiGroup") 36 | } 37 |
38 |
39 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the root of the repo. 2 | 3 | /* 4 | This file provides controller methods to get data from MS Graph. 5 | */ 6 | 7 | using Microsoft.Identity.Client; 8 | using System.IdentityModel.Tokens; 9 | using System.Collections.Generic; 10 | using System.Configuration; 11 | using System.Linq; 12 | using System.Security.Claims; 13 | using System.Threading.Tasks; 14 | using System.Web.Http; 15 | using System; 16 | using System.Net; 17 | using System.Net.Http; 18 | using Office_Add_in_ASPNET_SSO_WebAPI.Helpers; 19 | using Office_Add_in_ASPNET_SSO_WebAPI.Models; 20 | 21 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Controllers 22 | { 23 | 24 | public class ValuesController : ApiController 25 | { 26 | 27 | 28 | // GET api/values/5 29 | public string Get(int id) 30 | { 31 | return "value"; 32 | } 33 | 34 | // POST api/values 35 | public void Post([FromBody]string value) 36 | { 37 | } 38 | 39 | // PUT api/values/5 40 | public void Put(int id, [FromBody]string value) 41 | { 42 | } 43 | 44 | // DELETE api/values/5 45 | public void Delete(int id) 46 | { 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/Index.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using System.Web.Http.Controllers 3 | @using System.Web.Http.Description 4 | @using System.Collections.ObjectModel 5 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Models 6 | @model Collection 7 | 8 | @{ 9 | ViewBag.Title = "ASP.NET Web API Help Page"; 10 | 11 | // Group APIs by controller 12 | ILookup apiGroups = Model.ToLookup(api => api.ActionDescriptor.ControllerDescriptor); 13 | } 14 | 15 | 16 |
17 |
18 |
19 |

@ViewBag.Title

20 |
21 |
22 |
23 |
24 | 32 |
33 | @foreach (var group in apiGroups) 34 | { 35 | @Html.DisplayFor(m => group, "ApiGroup") 36 | } 37 |
38 |
39 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/ApiGroup.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using System.Web.Http.Controllers 3 | @using System.Web.Http.Description 4 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 5 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Models 6 | @model IGrouping 7 | 8 | @{ 9 | var controllerDocumentation = ViewBag.DocumentationProvider != null ? 10 | ViewBag.DocumentationProvider.GetDocumentation(Model.Key) : 11 | null; 12 | } 13 | 14 |

@Model.Key.ControllerName

15 | @if (!String.IsNullOrEmpty(controllerDocumentation)) 16 | { 17 |

@controllerDocumentation

18 | } 19 | 20 | 21 | 22 | 23 | 24 | @foreach (var api in Model) 25 | { 26 | 27 | 28 | 38 | 39 | } 40 | 41 |
APIDescription
@api.HttpMethod.Method @api.RelativePath 29 | @if (api.Documentation != null) 30 | { 31 |

@api.Documentation

32 | } 33 | else 34 | { 35 |

No documentation available.

36 | } 37 |
-------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/ApiGroup.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using System.Web.Http.Controllers 3 | @using System.Web.Http.Description 4 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 5 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Models 6 | @model IGrouping 7 | 8 | @{ 9 | var controllerDocumentation = ViewBag.DocumentationProvider != null ? 10 | ViewBag.DocumentationProvider.GetDocumentation(Model.Key) : 11 | null; 12 | } 13 | 14 |

@Model.Key.ControllerName

15 | @if (!String.IsNullOrEmpty(controllerDocumentation)) 16 | { 17 |

@controllerDocumentation

18 | } 19 | 20 | 21 | 22 | 23 | 24 | @foreach (var api in Model) 25 | { 26 | 27 | 28 | 38 | 39 | } 40 | 41 |
APIDescription
@api.HttpMethod.Method @api.RelativePath 29 | @if (api.Documentation != null) 30 | { 31 |

@api.Documentation

32 | } 33 | else 34 | { 35 |

No documentation available.

36 | } 37 |
-------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/App_Start/Startup.Auth.cs: -------------------------------------------------------------------------------- 1 | using Owin; 2 | using Microsoft.IdentityModel.Tokens; 3 | using System.Configuration; 4 | using Microsoft.Owin.Security.OAuth; 5 | using Microsoft.Owin.Security.Jwt; 6 | using Office_Add_in_ASPNET_SSO_WebAPI.App_Start; 7 | using System.Security.AccessControl; 8 | 9 | namespace Office_Add_in_ASPNET_SSO_WebAPI 10 | { 11 | public partial class Startup 12 | { 13 | public void ConfigureAuth(IAppBuilder app) 14 | { 15 | TokenValidationParameters tvps = new TokenValidationParameters 16 | { 17 | ValidAudience = ConfigurationManager.AppSettings["ida:Audience"], 18 | // Microsoft Accounts have an issuer GUID that is different from any organizational tenant GUID, 19 | // so to support both kinds of accounts, we do not validate the issuer. 20 | ValidateIssuer = false, 21 | SaveSigninToken = true 22 | }; 23 | 24 | string[] endAuthoritySegments = { "oauth2/v2.0" }; 25 | string[] parsedAuthority = ConfigurationManager.AppSettings["ida:Authority"].Split(endAuthoritySegments, System.StringSplitOptions.None); 26 | string wellKnownURL = parsedAuthority[0] + "v2.0/.well-known/openid-configuration"; 27 | 28 | app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions 29 | { 30 | AccessTokenFormat = new JwtFormat(tvps, new OpenIdConnectCachingSecurityTokenProvider(wellKnownURL)) 31 | }); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Models/MSGraphModels.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the root of the project. 2 | 3 | /* 4 | This file provides .NET model classes for Microsoft Graph data. 5 | */ 6 | 7 | using Newtonsoft.Json; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Web; 12 | 13 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Models 14 | { 15 | /// 16 | /// Models Microsoft Graph entities. 17 | /// 18 | /// 19 | /// There are many properties that almost all Microsoft Graph objects have. 20 | /// To avoid redundancy in the class definitions, use this abstract class. 21 | /// 22 | public abstract class MSGraphObject 23 | { 24 | public string Name { get; set; } 25 | } 26 | 27 | /// 28 | /// Objects that have an Etag. 29 | /// 30 | public interface IEtagable 31 | { 32 | // When the JSON property name begins with a character that cannot 33 | // begin a .NET property name, a JsonProperty attribute maps the names. 34 | [JsonProperty("@odata.etag")] 35 | string Etag { get; set; } 36 | } 37 | 38 | /// 39 | /// A OneDriveItem can be a file or folder. 40 | /// 41 | public class OneDriveItem : MSGraphObject, IEtagable 42 | { 43 | public string Etag { get; set;} 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Models/MSGraphModels.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the root of the project. 2 | 3 | /* 4 | This file provides .NET model classes for Microsoft Graph data. 5 | */ 6 | 7 | using Newtonsoft.Json; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Web; 12 | 13 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Models 14 | { 15 | /// 16 | /// Models Microsoft Graph entities. 17 | /// 18 | /// 19 | /// There are many properties that almost all Microsoft Graph objects have. 20 | /// To avoid redundancy in the class definitions, use this abstract class. 21 | /// 22 | public abstract class MSGraphObject 23 | { 24 | public string Name { get; set; } 25 | } 26 | 27 | /// 28 | /// Objects that have an Etag. 29 | /// 30 | public interface IEtagable 31 | { 32 | // When the JSON property name begins with a character that cannot 33 | // begin a .NET property name, a JsonProperty attribute maps the names. 34 | [JsonProperty("@odata.etag")] 35 | string Etag { get; set; } 36 | } 37 | 38 | /// 39 | /// A OneDriveItem can be a file or folder. 40 | /// 41 | public class OneDriveItem : MSGraphObject, IEtagable 42 | { 43 | public string Etag { get; set;} 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Office_Add_in_ASPNET_SSO_WebAPI")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Office_Add_in_ASPNET_SSO_WebAPI")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("035deac4-073c-41d1-a05c-94e916935291")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Office_Add_in_ASPNET_SSO_WebAPI")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Office_Add_in_ASPNET_SSO_WebAPI")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("035deac4-073c-41d1-a05c-94e916935291")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/ModelNameHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 7 | { 8 | internal static class ModelNameHelper 9 | { 10 | // Modify this to provide custom model name mapping. 11 | public static string GetModelName(Type type) 12 | { 13 | ModelNameAttribute modelNameAttribute = type.GetCustomAttribute(); 14 | if (modelNameAttribute != null && !String.IsNullOrEmpty(modelNameAttribute.Name)) 15 | { 16 | return modelNameAttribute.Name; 17 | } 18 | 19 | string modelName = type.Name; 20 | if (type.IsGenericType) 21 | { 22 | // Format the generic type name to something like: GenericOfAgurment1AndArgument2 23 | Type genericType = type.GetGenericTypeDefinition(); 24 | Type[] genericArguments = type.GetGenericArguments(); 25 | string genericTypeName = genericType.Name; 26 | 27 | // Trim the generic parameter counts from the name 28 | genericTypeName = genericTypeName.Substring(0, genericTypeName.IndexOf('`')); 29 | string[] argumentTypeNames = genericArguments.Select(t => GetModelName(t)).ToArray(); 30 | modelName = String.Format(CultureInfo.InvariantCulture, "{0}Of{1}", genericTypeName, String.Join("And", argumentTypeNames)); 31 | } 32 | 33 | return modelName; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ModelDescriptions/ModelNameHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Linq; 4 | using System.Reflection; 5 | 6 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 7 | { 8 | internal static class ModelNameHelper 9 | { 10 | // Modify this to provide custom model name mapping. 11 | public static string GetModelName(Type type) 12 | { 13 | ModelNameAttribute modelNameAttribute = type.GetCustomAttribute(); 14 | if (modelNameAttribute != null && !String.IsNullOrEmpty(modelNameAttribute.Name)) 15 | { 16 | return modelNameAttribute.Name; 17 | } 18 | 19 | string modelName = type.Name; 20 | if (type.IsGenericType) 21 | { 22 | // Format the generic type name to something like: GenericOfAgurment1AndArgument2 23 | Type genericType = type.GetGenericTypeDefinition(); 24 | Type[] genericArguments = type.GetGenericArguments(); 25 | string genericTypeName = genericType.Name; 26 | 27 | // Trim the generic parameter counts from the name 28 | genericTypeName = genericTypeName.Substring(0, genericTypeName.IndexOf('`')); 29 | string[] argumentTypeNames = genericArguments.Select(t => GetModelName(t)).ToArray(); 30 | modelName = String.Format(CultureInfo.InvariantCulture, "{0}Of{1}", genericTypeName, String.Join("And", argumentTypeNames)); 31 | } 32 | 33 | return modelName; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ApiDescriptionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using System.Web; 4 | using System.Web.Http.Description; 5 | 6 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 7 | { 8 | public static class ApiDescriptionExtensions 9 | { 10 | /// 11 | /// Generates an URI-friendly ID for the . E.g. "Get-Values-id_name" instead of "GetValues/{id}?name={name}" 12 | /// 13 | /// The . 14 | /// The ID as a string. 15 | public static string GetFriendlyId(this ApiDescription description) 16 | { 17 | string path = description.RelativePath; 18 | string[] urlParts = path.Split('?'); 19 | string localPath = urlParts[0]; 20 | string queryKeyString = null; 21 | if (urlParts.Length > 1) 22 | { 23 | string query = urlParts[1]; 24 | string[] queryKeys = HttpUtility.ParseQueryString(query).AllKeys; 25 | queryKeyString = String.Join("_", queryKeys); 26 | } 27 | 28 | StringBuilder friendlyPath = new StringBuilder(); 29 | friendlyPath.AppendFormat("{0}-{1}", 30 | description.HttpMethod.Method, 31 | localPath.Replace("/", "-").Replace("{", String.Empty).Replace("}", String.Empty)); 32 | if (queryKeyString != null) 33 | { 34 | friendlyPath.AppendFormat("_{0}", queryKeyString.Replace('.', '-')); 35 | } 36 | return friendlyPath.ToString(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/ApiDescriptionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using System.Web; 4 | using System.Web.Http.Description; 5 | 6 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage 7 | { 8 | public static class ApiDescriptionExtensions 9 | { 10 | /// 11 | /// Generates an URI-friendly ID for the . E.g. "Get-Values-id_name" instead of "GetValues/{id}?name={name}" 12 | /// 13 | /// The . 14 | /// The ID as a string. 15 | public static string GetFriendlyId(this ApiDescription description) 16 | { 17 | string path = description.RelativePath; 18 | string[] urlParts = path.Split('?'); 19 | string localPath = urlParts[0]; 20 | string queryKeyString = null; 21 | if (urlParts.Length > 1) 22 | { 23 | string query = urlParts[1]; 24 | string[] queryKeys = HttpUtility.ParseQueryString(query).AllKeys; 25 | queryKeyString = String.Join("_", queryKeys); 26 | } 27 | 28 | StringBuilder friendlyPath = new StringBuilder(); 29 | friendlyPath.AppendFormat("{0}-{1}", 30 | description.HttpMethod.Method, 31 | localPath.Replace("/", "-").Replace("{", String.Empty).Replace("}", String.Empty)); 32 | if (queryKeyString != null) 33 | { 34 | friendlyPath.AppendFormat("_{0}", queryKeyString.Replace('.', '-')); 35 | } 36 | return friendlyPath.ToString(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | @if (this.Context.IsDebuggingEnabled) 9 | { 10 | 11 | 12 | 13 | } 14 | 15 | @ViewBag.Title 16 | 17 | @Styles.Render("~/Content/css") 18 | 19 | 20 | @* This office.js library holds the JavaScript API for Office.*@ 21 | @**@ 22 | 23 | 24 | @*To use a local copy of the Office JavaScript library, comment the preceding line and uncomment the following line. 25 | *@ 26 | 27 | @* The following two files hold the Office UI Fabric styles and components. *@ 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 | @RenderBody() 36 |
37 | 38 | @RenderSection("scripts", required: false) 39 | 40 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | @if (this.Context.IsDebuggingEnabled) 9 | { 10 | 11 | 12 | 13 | } 14 | 15 | @ViewBag.Title 16 | 17 | @Styles.Render("~/Content/css") 18 | 19 | 20 | @* This office.js library holds the JavaScript API for Office.*@ 21 | @**@ 22 | 23 | 24 | @*To use a local copy of the Office JavaScript library, comment the preceding line and uncomment the following line. 25 | *@ 26 | 27 | @* The following two files hold the Office UI Fabric styles and components. *@ 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 | @RenderBody() 36 |
37 | 38 | @RenderSection("scripts", required: false) 39 | 40 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/Parameters.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Collections.Generic 2 | @using System.Collections.ObjectModel 3 | @using System.Web.Http.Description 4 | @using System.Threading 5 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 6 | @model IList 7 | 8 | @if (Model.Count > 0) 9 | { 10 | 11 | 12 | 13 | 14 | 15 | @foreach (ParameterDescription parameter in Model) 16 | { 17 | ModelDescription modelDescription = parameter.TypeDescription; 18 | 19 | 20 | 23 | 26 | 39 | 40 | } 41 | 42 |
NameDescriptionTypeAdditional information
@parameter.Name 21 |

@parameter.Documentation

22 |
24 | @Html.DisplayFor(m => modelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = modelDescription }) 25 | 27 | @if (parameter.Annotations.Count > 0) 28 | { 29 | foreach (var annotation in parameter.Annotations) 30 | { 31 |

@annotation.Documentation

32 | } 33 | } 34 | else 35 | { 36 |

None.

37 | } 38 |
43 | } 44 | else 45 | { 46 |

None.

47 | } 48 | 49 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/Parameters.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Collections.Generic 2 | @using System.Collections.ObjectModel 3 | @using System.Web.Http.Description 4 | @using System.Threading 5 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 6 | @model IList 7 | 8 | @if (Model.Count > 0) 9 | { 10 | 11 | 12 | 13 | 14 | 15 | @foreach (ParameterDescription parameter in Model) 16 | { 17 | ModelDescription modelDescription = parameter.TypeDescription; 18 | 19 | 20 | 23 | 26 | 39 | 40 | } 41 | 42 |
NameDescriptionTypeAdditional information
@parameter.Name 21 |

@parameter.Documentation

22 |
24 | @Html.DisplayFor(m => modelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = modelDescription }) 25 | 27 | @if (parameter.Annotations.Count > 0) 28 | { 29 | foreach (var annotation in parameter.Annotations) 30 | { 31 |

@annotation.Documentation

32 | } 33 | } 34 | else 35 | { 36 |

None.

37 | } 38 |
43 | } 44 | else 45 | { 46 |

None.

47 | } 48 | 49 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Scripts/_officeintellisense.js: -------------------------------------------------------------------------------- 1 | // This file is generated by Visual Studio to enable IntelliSense for the Office JavaScript Object Model. 2 | 3 | var Office = new function() { 4 | this._appContext = 16; 5 | this._showAll = true; 6 | this._setContext = { 7 | 8 | }; 9 | } 10 | 11 | // 1 Excel appContext = 001 12 | // 2 Word appContext = 010 13 | // 3 Word + Excel appContext = 011 14 | // 4 Project appContext = 100 15 | // 5 Project + Excel appContext = 101 16 | // 6 Project + Word appContext = 110 17 | // 7 Project + Word + Excel appContext = 111 18 | // 8 Outlook read-form appContext = 1000 19 | // 16 PowerPoint appContext = 10000 20 | // 17 PowerPoint + Excel appContext = 10001 21 | // 18 PowerPoint + Word appContext = 10010 22 | // 19 PowerPoint + Word + Excel appContext = 10011 23 | // 20 PowerPoint + Project appContext = 10100 24 | // 21 PowerPoint + Project + Excel appContext = 10101 25 | // 22 PowerPoint + Project + Word appContext = 10110 26 | // 23 PowerPoint + Project + Word + Excel appContext = 10111 27 | // 32 Outlook compose-form appContext = 100000 28 | // 40 Outlook read-form + Outlook compose form appContext = 101000 29 | // 64 Access appContext = 1000000 30 | // 65 Access + Excel appContext = 1000001 31 | // 66 Access + Word appContext = 1000010 32 | // 67 Access + Word + Excel appContext = 1000011 33 | // 68 Access + Project appContext = 1000100 34 | // 69 Access + Project + Excel appContext = 1000101 35 | // 70 Access + Project + Word appContext = 1000110 36 | // 71 Access + Project + Word + Excel appContext = 1000111 37 | // 80 Access + PowerPoint appContext = 1010000 38 | // 81 Access + PowerPoint + Excel appContext = 1010001 39 | // 82 Access + PowerPoint + Word appContext = 1010010 40 | // 83 Access + PowerPoint + Word + Excel appContext = 1010011 41 | // 84 Access + PowerPoint + Project appContext = 1010100 42 | // 85 Access + PowerPoint + Project + Excel appContext = 1010101 43 | // 86 Access + PowerPoint + Project + Word appContext = 1010110 44 | // 87 Access + PowerPoint + Project + Word + Excel appContext = 1010111 45 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Scripts/_officeintellisense.js: -------------------------------------------------------------------------------- 1 | // This file is generated by Visual Studio to enable IntelliSense for the Office JavaScript Object Model. 2 | 3 | var Office = new function() { 4 | this._appContext = 16; 5 | this._showAll = true; 6 | this._setContext = { 7 | 8 | }; 9 | } 10 | 11 | // 1 Excel appContext = 001 12 | // 2 Word appContext = 010 13 | // 3 Word + Excel appContext = 011 14 | // 4 Project appContext = 100 15 | // 5 Project + Excel appContext = 101 16 | // 6 Project + Word appContext = 110 17 | // 7 Project + Word + Excel appContext = 111 18 | // 8 Outlook read-form appContext = 1000 19 | // 16 PowerPoint appContext = 10000 20 | // 17 PowerPoint + Excel appContext = 10001 21 | // 18 PowerPoint + Word appContext = 10010 22 | // 19 PowerPoint + Word + Excel appContext = 10011 23 | // 20 PowerPoint + Project appContext = 10100 24 | // 21 PowerPoint + Project + Excel appContext = 10101 25 | // 22 PowerPoint + Project + Word appContext = 10110 26 | // 23 PowerPoint + Project + Word + Excel appContext = 10111 27 | // 32 Outlook compose-form appContext = 100000 28 | // 40 Outlook read-form + Outlook compose form appContext = 101000 29 | // 64 Access appContext = 1000000 30 | // 65 Access + Excel appContext = 1000001 31 | // 66 Access + Word appContext = 1000010 32 | // 67 Access + Word + Excel appContext = 1000011 33 | // 68 Access + Project appContext = 1000100 34 | // 69 Access + Project + Excel appContext = 1000101 35 | // 70 Access + Project + Word appContext = 1000110 36 | // 71 Access + Project + Word + Excel appContext = 1000111 37 | // 80 Access + PowerPoint appContext = 1010000 38 | // 81 Access + PowerPoint + Excel appContext = 1010001 39 | // 82 Access + PowerPoint + Word appContext = 1010010 40 | // 83 Access + PowerPoint + Word + Excel appContext = 1010011 41 | // 84 Access + PowerPoint + Project appContext = 1010100 42 | // 85 Access + PowerPoint + Project + Excel appContext = 1010101 43 | // 86 Access + PowerPoint + Project + Word appContext = 1010110 44 | // 87 Access + PowerPoint + Project + Word + Excel appContext = 1010111 45 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Views/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Views/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/HelpPageApiModel.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using System.Web.Http.Description 3 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Models 4 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 5 | @model HelpPageApiModel 6 | 7 | @{ 8 | ApiDescription description = Model.ApiDescription; 9 | } 10 |

@description.HttpMethod.Method @description.RelativePath

11 |
12 |

@description.Documentation

13 | 14 |

Request Information

15 | 16 |

URI Parameters

17 | @Html.DisplayFor(m => m.UriParameters, "Parameters") 18 | 19 |

Body Parameters

20 | 21 |

@Model.RequestDocumentation

22 | 23 | @if (Model.RequestModelDescription != null) 24 | { 25 | @Html.DisplayFor(m => m.RequestModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.RequestModelDescription }) 26 | if (Model.RequestBodyParameters != null) 27 | { 28 | @Html.DisplayFor(m => m.RequestBodyParameters, "Parameters") 29 | } 30 | } 31 | else 32 | { 33 |

None.

34 | } 35 | 36 | @if (Model.SampleRequests.Count > 0) 37 | { 38 |

Request Formats

39 | @Html.DisplayFor(m => m.SampleRequests, "Samples") 40 | } 41 | 42 |

Response Information

43 | 44 |

Resource Description

45 | 46 |

@description.ResponseDescription.Documentation

47 | 48 | @if (Model.ResourceDescription != null) 49 | { 50 | @Html.DisplayFor(m => m.ResourceDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ResourceDescription }) 51 | if (Model.ResourceProperties != null) 52 | { 53 | @Html.DisplayFor(m => m.ResourceProperties, "Parameters") 54 | } 55 | } 56 | else 57 | { 58 |

None.

59 | } 60 | 61 | @if (Model.SampleResponses.Count > 0) 62 | { 63 |

Response Formats

64 | @Html.DisplayFor(m => m.SampleResponses, "Samples") 65 | } 66 | 67 |
-------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Views/Help/DisplayTemplates/HelpPageApiModel.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web.Http 2 | @using System.Web.Http.Description 3 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Models 4 | @using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions 5 | @model HelpPageApiModel 6 | 7 | @{ 8 | ApiDescription description = Model.ApiDescription; 9 | } 10 |

@description.HttpMethod.Method @description.RelativePath

11 |
12 |

@description.Documentation

13 | 14 |

Request Information

15 | 16 |

URI Parameters

17 | @Html.DisplayFor(m => m.UriParameters, "Parameters") 18 | 19 |

Body Parameters

20 | 21 |

@Model.RequestDocumentation

22 | 23 | @if (Model.RequestModelDescription != null) 24 | { 25 | @Html.DisplayFor(m => m.RequestModelDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.RequestModelDescription }) 26 | if (Model.RequestBodyParameters != null) 27 | { 28 | @Html.DisplayFor(m => m.RequestBodyParameters, "Parameters") 29 | } 30 | } 31 | else 32 | { 33 |

None.

34 | } 35 | 36 | @if (Model.SampleRequests.Count > 0) 37 | { 38 |

Request Formats

39 | @Html.DisplayFor(m => m.SampleRequests, "Samples") 40 | } 41 | 42 |

Response Information

43 | 44 |

Resource Description

45 | 46 |

@description.ResponseDescription.Documentation

47 | 48 | @if (Model.ResourceDescription != null) 49 | { 50 | @Html.DisplayFor(m => m.ResourceDescription.ModelType, "ModelDescriptionLink", new { modelDescription = Model.ResourceDescription }) 51 | if (Model.ResourceProperties != null) 52 | { 53 | @Html.DisplayFor(m => m.ResourceProperties, "Parameters") 54 | } 55 | } 56 | else 57 | { 58 |

None.

59 | } 60 | 61 | @if (Model.SampleResponses.Count > 0) 62 | { 63 |

Response Formats

64 | @Html.DisplayFor(m => m.SampleResponses, "Samples") 65 | } 66 | 67 |
-------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Controllers/HelpController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.Http; 3 | using System.Web.Mvc; 4 | using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions; 5 | using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Models; 6 | 7 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Controllers 8 | { 9 | /// 10 | /// The controller that will handle requests for the help page. 11 | /// 12 | public class HelpController : Controller 13 | { 14 | private const string ErrorViewName = "Error"; 15 | 16 | public HelpController() 17 | : this(GlobalConfiguration.Configuration) 18 | { 19 | } 20 | 21 | public HelpController(HttpConfiguration config) 22 | { 23 | Configuration = config; 24 | } 25 | 26 | public HttpConfiguration Configuration { get; private set; } 27 | 28 | public ActionResult Index() 29 | { 30 | ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider(); 31 | return View(Configuration.Services.GetApiExplorer().ApiDescriptions); 32 | } 33 | 34 | public ActionResult Api(string apiId) 35 | { 36 | if (!String.IsNullOrEmpty(apiId)) 37 | { 38 | HelpPageApiModel apiModel = Configuration.GetHelpPageApiModel(apiId); 39 | if (apiModel != null) 40 | { 41 | return View(apiModel); 42 | } 43 | } 44 | 45 | return View(ErrorViewName); 46 | } 47 | 48 | public ActionResult ResourceModel(string modelName) 49 | { 50 | if (!String.IsNullOrEmpty(modelName)) 51 | { 52 | ModelDescriptionGenerator modelDescriptionGenerator = Configuration.GetModelDescriptionGenerator(); 53 | ModelDescription modelDescription; 54 | if (modelDescriptionGenerator.GeneratedModels.TryGetValue(modelName, out modelDescription)) 55 | { 56 | return View(modelDescription); 57 | } 58 | } 59 | 60 | return View(ErrorViewName); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Controllers/HelpController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.Http; 3 | using System.Web.Mvc; 4 | using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions; 5 | using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Models; 6 | 7 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Controllers 8 | { 9 | /// 10 | /// The controller that will handle requests for the help page. 11 | /// 12 | public class HelpController : Controller 13 | { 14 | private const string ErrorViewName = "Error"; 15 | 16 | public HelpController() 17 | : this(GlobalConfiguration.Configuration) 18 | { 19 | } 20 | 21 | public HelpController(HttpConfiguration config) 22 | { 23 | Configuration = config; 24 | } 25 | 26 | public HttpConfiguration Configuration { get; private set; } 27 | 28 | public ActionResult Index() 29 | { 30 | ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider(); 31 | return View(Configuration.Services.GetApiExplorer().ApiDescriptions); 32 | } 33 | 34 | public ActionResult Api(string apiId) 35 | { 36 | if (!String.IsNullOrEmpty(apiId)) 37 | { 38 | HelpPageApiModel apiModel = Configuration.GetHelpPageApiModel(apiId); 39 | if (apiModel != null) 40 | { 41 | return View(apiModel); 42 | } 43 | } 44 | 45 | return View(ErrorViewName); 46 | } 47 | 48 | public ActionResult ResourceModel(string modelName) 49 | { 50 | if (!String.IsNullOrEmpty(modelName)) 51 | { 52 | ModelDescriptionGenerator modelDescriptionGenerator = Configuration.GetModelDescriptionGenerator(); 53 | ModelDescription modelDescription; 54 | if (modelDescriptionGenerator.GeneratedModels.TryGetValue(modelName, out modelDescription)) 55 | { 56 | return View(modelDescription); 57 | } 58 | } 59 | 60 | return View(ErrorViewName); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @*Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo.*@ 2 | 3 | @{ 4 | ViewBag.Title = "Home Page"; 5 | } 6 | 7 | 8 | 9 | 10 | @Scripts.Render("~/bundles/OfficeAddinMicrosoftGraphASPNET") 11 | 12 | 13 |
14 |
15 |
Welcome
16 |
This add-in demonstrates how to connect to Microsoft Graph from an add-in.
17 | 18 |
19 |
20 |

This add-in performs the following tasks:

21 | 22 |
    23 |
  • 24 | 1 25 | Connects to OneDrive. 26 |
    27 |
  • 28 |
  • 29 | 2 30 | Gets the names of the first ten files and folders in OneDrive . 31 |
    32 |
  • 33 |
  • 34 | 3 35 | Adds the names to the current document. 36 |
    37 |
  • 38 |
39 |
40 |
41 | 42 | 46 | 47 | @* Custom CSS "homefooter" class is fixed to the bottom of the page so it is visible even if the task pane is scrolled. *@ 48 |
49 |
50 | 51 | @* Button to sign in to get Microsoft Graph data *@ 52 |

53 | 54 |

55 | 56 |
57 |
58 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @*Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo.*@ 2 | 3 | @{ 4 | ViewBag.Title = "Home Page"; 5 | } 6 | 7 | 8 | 9 | 10 | @Scripts.Render("~/bundles/OfficeAddinMicrosoftGraphASPNET") 11 | 12 | 13 |
14 |
15 |
Welcome
16 |
This add-in demonstrates how to connect to Microsoft Graph from an add-in.
17 | 18 |
19 |
20 |

This add-in performs the following tasks:

21 | 22 |
    23 |
  • 24 | 1 25 | Connects to OneDrive. 26 |
    27 |
  • 28 |
  • 29 | 2 30 | Gets the names of the first ten files and folders in OneDrive . 31 |
    32 |
  • 33 |
  • 34 | 3 35 | Adds the names to the current document. 36 |
    37 |
  • 38 |
39 |
40 |
41 | 42 | 46 | 47 | @* Custom CSS "homefooter" class is fixed to the bottom of the page so it is visible even if the task pane is scrolled. *@ 48 |
49 |
50 | 51 | @* Button to sign in to get Microsoft Graph data *@ 52 |

53 | 54 |

55 | 56 |
57 |
58 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Scripts/Document.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo. 2 | 3 | "use strict"; 4 | 5 | 6 | 7 | function writeFileNamesToOfficeDocument(result) { 8 | 9 | return new OfficeExtension.Promise(function (resolve, reject) { 10 | try { 11 | switch (Office.context.host) { 12 | case "Excel": 13 | writeFileNamesToWorksheet(result); 14 | break; 15 | case "Word": 16 | writeFileNamesToDocument(result); 17 | break; 18 | case "PowerPoint": 19 | writeFileNamesToPresentation(result); 20 | break; 21 | default: 22 | throw "Unsupported Office host application: This add-in only runs on Excel, PowerPoint, or Word."; 23 | } 24 | resolve(); 25 | } 26 | catch (error) { 27 | reject(Error("Unable to add filenames to document. " + error.toString())); 28 | } 29 | }); 30 | } 31 | 32 | function writeFileNamesToWorksheet(result) { 33 | 34 | return Excel.run(function (context) { 35 | var sheet = context.workbook.worksheets.getActiveWorksheet(); 36 | 37 | var filenames = []; 38 | var i; 39 | for (i = 0; i < result.length; i++) { 40 | var innerArray = []; 41 | innerArray.push(result[i]); 42 | filenames.push(innerArray); 43 | } 44 | 45 | var rangeAddress = "B5:B" + (5 + (result.length - 1)).toString(); 46 | var range = sheet.getRange(rangeAddress); 47 | range.values = filenames; 48 | range.format.autofitColumns(); 49 | 50 | return context.sync(); 51 | }); 52 | } 53 | 54 | function writeFileNamesToDocument(result) { 55 | 56 | return Word.run(function (context) { 57 | 58 | var documentBody = context.document.body; 59 | for (var i = 0; i < result.length; i++) { 60 | documentBody.insertParagraph(result[i], "End"); 61 | } 62 | 63 | return context.sync(); 64 | }); 65 | } 66 | 67 | function writeFileNamesToPresentation(result) { 68 | 69 | var fileNames = ""; 70 | for (var i = 0; i < result.length; i++) { 71 | fileNames += result[i] + '\n'; 72 | } 73 | 74 | Office.context.document.setSelectedDataAsync( 75 | fileNames, 76 | function (asyncResult) { 77 | if (asyncResult.status === Office.AsyncResultStatus.Failed) { 78 | throw asyncResult.error.message; 79 | } 80 | } 81 | ); 82 | } 83 | 84 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Scripts/Document.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo. 2 | 3 | "use strict"; 4 | 5 | 6 | 7 | function writeFileNamesToOfficeDocument(result) { 8 | 9 | return new OfficeExtension.Promise(function (resolve, reject) { 10 | try { 11 | switch (Office.context.host) { 12 | case "Excel": 13 | writeFileNamesToWorksheet(result); 14 | break; 15 | case "Word": 16 | writeFileNamesToDocument(result); 17 | break; 18 | case "PowerPoint": 19 | writeFileNamesToPresentation(result); 20 | break; 21 | default: 22 | throw "Unsupported Office host application: This add-in only runs on Excel, PowerPoint, or Word."; 23 | } 24 | resolve(); 25 | } 26 | catch (error) { 27 | reject(Error("Unable to add filenames to document. " + error.toString())); 28 | } 29 | }); 30 | } 31 | 32 | function writeFileNamesToWorksheet(result) { 33 | 34 | return Excel.run(function (context) { 35 | var sheet = context.workbook.worksheets.getActiveWorksheet(); 36 | 37 | var filenames = []; 38 | var i; 39 | for (i = 0; i < result.length; i++) { 40 | var innerArray = []; 41 | innerArray.push(result[i]); 42 | filenames.push(innerArray); 43 | } 44 | 45 | var rangeAddress = "B5:B" + (5 + (result.length - 1)).toString(); 46 | var range = sheet.getRange(rangeAddress); 47 | range.values = filenames; 48 | range.format.autofitColumns(); 49 | 50 | return context.sync(); 51 | }); 52 | } 53 | 54 | function writeFileNamesToDocument(result) { 55 | 56 | return Word.run(function (context) { 57 | 58 | var documentBody = context.document.body; 59 | for (var i = 0; i < result.length; i++) { 60 | documentBody.insertParagraph(result[i], "End"); 61 | } 62 | 63 | return context.sync(); 64 | }); 65 | } 66 | 67 | function writeFileNamesToPresentation(result) { 68 | 69 | var fileNames = ""; 70 | for (var i = 0; i < result.length; i++) { 71 | fileNames += result[i] + '\n'; 72 | } 73 | 74 | Office.context.document.setSelectedDataAsync( 75 | fileNames, 76 | function (asyncResult) { 77 | if (asyncResult.status === Office.AsyncResultStatus.Failed) { 78 | throw asyncResult.error.message; 79 | } 80 | } 81 | ); 82 | } 83 | 84 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Helpers/GraphApiHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the root of the project. 2 | 3 | /* 4 | This file provides URLs to help get Microsoft Graph data. 5 | */ 6 | 7 | using System; 8 | using System.Net; 9 | using System.Net.Http; 10 | using System.Threading.Tasks; 11 | using System.Collections.Generic; 12 | using Office_Add_in_ASPNET_SSO_WebAPI.Models; 13 | using System.Web.Http; 14 | 15 | 16 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Helpers 17 | { 18 | /// 19 | /// Provides methods and strings for Microsoft Graph-specific endpoints. 20 | /// 21 | internal static class GraphApiHelper 22 | { 23 | // Microsoft Graph-related base URLs 24 | internal static string GetFilesUrl = @"https://graph.microsoft.com/v1.0/me/drive/root/children"; 25 | 26 | // The selectedProperties parameter is a query parameter that will be added 27 | // to the Microsoft Graph REST API URL. If any part of it comes from user input, 28 | // be sure that it is sanitized so that it cannot be used in 29 | // a Response header injection attack. 30 | internal static string GetOneDriveItemNamesUrl(string selectedProperties) 31 | { 32 | // Construct URL for the names of the folders and files. 33 | return GetFilesUrl + selectedProperties; 34 | } 35 | 36 | internal static async Task GetOneDriveFileNames(string accessToken) 37 | { 38 | // Get the names of files and folders in OneDrive by using the Microsoft Graph API. 39 | var fullOneDriveItemsUrl = GetOneDriveItemNamesUrl("?$select=name&$top=10"); 40 | IEnumerable filesResult; 41 | try 42 | { 43 | filesResult = await ODataHelper.GetItems(fullOneDriveItemsUrl, accessToken); 44 | } 45 | catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) 46 | { 47 | return HttpErrorHelper.SendErrorToClient(HttpStatusCode.Unauthorized, e, null); 48 | } 49 | 50 | // Remove excess information from the data and send the data to the client. 51 | List itemNames = new List(); 52 | foreach (OneDriveItem item in filesResult) 53 | { 54 | itemNames.Add(item.Name); 55 | } 56 | 57 | var requestMessage = new HttpRequestMessage(); 58 | requestMessage.SetConfiguration(new HttpConfiguration()); 59 | var response = requestMessage.CreateResponse>(HttpStatusCode.OK, itemNames); 60 | return response; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26424.2 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Office-Add-in-ASPNET-SSO", "Office-Add-in-ASPNET-SSO\Office-Add-in-ASPNET-SSO.csproj", "{E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Office-Add-in-ASPNET-SSO-WebAPI", "Office-Add-in-ASPNET-SSO-WebAPI\Office-Add-in-ASPNET-SSO-WebAPI.csproj", "{FCEBFFAD-8183-4284-82F5-F15465DFAFA8}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Release|Any CPU = Release|Any CPU 15 | Release|x64 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 21 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Debug|x64.ActiveCfg = Debug|x64 22 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Debug|x64.Build.0 = Debug|x64 23 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Debug|x64.Deploy.0 = Debug|x64 24 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Release|Any CPU.Deploy.0 = Release|Any CPU 27 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Release|x64.ActiveCfg = Release|x64 28 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Release|x64.Build.0 = Release|x64 29 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Release|x64.Deploy.0 = Release|x64 30 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Debug|x64.ActiveCfg = Debug|Any CPU 33 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Debug|x64.Build.0 = Debug|Any CPU 34 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Release|x64.ActiveCfg = Release|Any CPU 37 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Release|x64.Build.0 = Release|Any CPU 38 | EndGlobalSection 39 | GlobalSection(SolutionProperties) = preSolution 40 | HideSolutionNode = FALSE 41 | EndGlobalSection 42 | GlobalSection(ExtensibilityGlobals) = postSolution 43 | SolutionGuid = {C806A8C8-1F3A-4149-8406-11C905C322F2} 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26424.2 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Office-Add-in-ASPNET-SSO", "Office-Add-in-ASPNET-SSO\Office-Add-in-ASPNET-SSO.csproj", "{E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Office-Add-in-ASPNET-SSO-WebAPI", "Office-Add-in-ASPNET-SSO-WebAPI\Office-Add-in-ASPNET-SSO-WebAPI.csproj", "{FCEBFFAD-8183-4284-82F5-F15465DFAFA8}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Release|Any CPU = Release|Any CPU 15 | Release|x64 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 21 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Debug|x64.ActiveCfg = Debug|x64 22 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Debug|x64.Build.0 = Debug|x64 23 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Debug|x64.Deploy.0 = Debug|x64 24 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Release|Any CPU.Deploy.0 = Release|Any CPU 27 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Release|x64.ActiveCfg = Release|x64 28 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Release|x64.Build.0 = Release|x64 29 | {E67B9448-E0DB-4A4B-B5F6-2DA56F94BCDC}.Release|x64.Deploy.0 = Release|x64 30 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Debug|x64.ActiveCfg = Debug|Any CPU 33 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Debug|x64.Build.0 = Debug|Any CPU 34 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Release|x64.ActiveCfg = Release|Any CPU 37 | {FCEBFFAD-8183-4284-82F5-F15465DFAFA8}.Release|x64.Build.0 = Release|Any CPU 38 | EndGlobalSection 39 | GlobalSection(SolutionProperties) = preSolution 40 | HideSolutionNode = FALSE 41 | EndGlobalSection 42 | GlobalSection(ExtensibilityGlobals) = postSolution 43 | SolutionGuid = {C806A8C8-1F3A-4149-8406-11C905C322F2} 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/HelpPage.css: -------------------------------------------------------------------------------- 1 | .help-page h1, 2 | .help-page .h1, 3 | .help-page h2, 4 | .help-page .h2, 5 | .help-page h3, 6 | .help-page .h3, 7 | #body.help-page, 8 | .help-page-table th, 9 | .help-page-table pre, 10 | .help-page-table p { 11 | font-family: "Segoe UI Light", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; 12 | } 13 | 14 | .help-page pre.wrapped { 15 | white-space: -moz-pre-wrap; 16 | white-space: -pre-wrap; 17 | white-space: -o-pre-wrap; 18 | white-space: pre-wrap; 19 | } 20 | 21 | .help-page .warning-message-container { 22 | margin-top: 20px; 23 | padding: 0 10px; 24 | color: #525252; 25 | background: #EFDCA9; 26 | border: 1px solid #CCCCCC; 27 | } 28 | 29 | .help-page-table { 30 | width: 100%; 31 | border-collapse: collapse; 32 | text-align: left; 33 | margin: 0px 0px 20px 0px; 34 | border-top: 1px solid #D4D4D4; 35 | } 36 | 37 | .help-page-table th { 38 | text-align: left; 39 | font-weight: bold; 40 | border-bottom: 1px solid #D4D4D4; 41 | padding: 5px 6px 5px 6px; 42 | } 43 | 44 | .help-page-table td { 45 | border-bottom: 1px solid #D4D4D4; 46 | padding: 10px 8px 10px 8px; 47 | vertical-align: top; 48 | } 49 | 50 | .help-page-table pre, 51 | .help-page-table p { 52 | margin: 0px; 53 | padding: 0px; 54 | font-family: inherit; 55 | font-size: 100%; 56 | } 57 | 58 | .help-page-table tbody tr:hover td { 59 | background-color: #F3F3F3; 60 | } 61 | 62 | .help-page a:hover { 63 | background-color: transparent; 64 | } 65 | 66 | .help-page .sample-header { 67 | border: 2px solid #D4D4D4; 68 | background: #00497E; 69 | color: #FFFFFF; 70 | padding: 8px 15px; 71 | border-bottom: none; 72 | display: inline-block; 73 | margin: 10px 0px 0px 0px; 74 | } 75 | 76 | .help-page .sample-content { 77 | display: block; 78 | border-width: 0; 79 | padding: 15px 20px; 80 | background: #FFFFFF; 81 | border: 2px solid #D4D4D4; 82 | margin: 0px 0px 10px 0px; 83 | } 84 | 85 | .help-page .api-name { 86 | width: 40%; 87 | } 88 | 89 | .help-page .api-documentation { 90 | width: 60%; 91 | } 92 | 93 | .help-page .parameter-name { 94 | width: 20%; 95 | } 96 | 97 | .help-page .parameter-documentation { 98 | width: 40%; 99 | } 100 | 101 | .help-page .parameter-type { 102 | width: 20%; 103 | } 104 | 105 | .help-page .parameter-annotations { 106 | width: 20%; 107 | } 108 | 109 | .help-page h1, 110 | .help-page .h1 { 111 | font-size: 36px; 112 | line-height: normal; 113 | } 114 | 115 | .help-page h2, 116 | .help-page .h2 { 117 | font-size: 24px; 118 | } 119 | 120 | .help-page h3, 121 | .help-page .h3 { 122 | font-size: 20px; 123 | } 124 | 125 | #body.help-page { 126 | font-size: 14px; 127 | line-height: 143%; 128 | color: #333; 129 | } 130 | 131 | .help-page a { 132 | color: #0000EE; 133 | text-decoration: none; 134 | } 135 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/HelpPage.css: -------------------------------------------------------------------------------- 1 | .help-page h1, 2 | .help-page .h1, 3 | .help-page h2, 4 | .help-page .h2, 5 | .help-page h3, 6 | .help-page .h3, 7 | #body.help-page, 8 | .help-page-table th, 9 | .help-page-table pre, 10 | .help-page-table p { 11 | font-family: "Segoe UI Light", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; 12 | } 13 | 14 | .help-page pre.wrapped { 15 | white-space: -moz-pre-wrap; 16 | white-space: -pre-wrap; 17 | white-space: -o-pre-wrap; 18 | white-space: pre-wrap; 19 | } 20 | 21 | .help-page .warning-message-container { 22 | margin-top: 20px; 23 | padding: 0 10px; 24 | color: #525252; 25 | background: #EFDCA9; 26 | border: 1px solid #CCCCCC; 27 | } 28 | 29 | .help-page-table { 30 | width: 100%; 31 | border-collapse: collapse; 32 | text-align: left; 33 | margin: 0px 0px 20px 0px; 34 | border-top: 1px solid #D4D4D4; 35 | } 36 | 37 | .help-page-table th { 38 | text-align: left; 39 | font-weight: bold; 40 | border-bottom: 1px solid #D4D4D4; 41 | padding: 5px 6px 5px 6px; 42 | } 43 | 44 | .help-page-table td { 45 | border-bottom: 1px solid #D4D4D4; 46 | padding: 10px 8px 10px 8px; 47 | vertical-align: top; 48 | } 49 | 50 | .help-page-table pre, 51 | .help-page-table p { 52 | margin: 0px; 53 | padding: 0px; 54 | font-family: inherit; 55 | font-size: 100%; 56 | } 57 | 58 | .help-page-table tbody tr:hover td { 59 | background-color: #F3F3F3; 60 | } 61 | 62 | .help-page a:hover { 63 | background-color: transparent; 64 | } 65 | 66 | .help-page .sample-header { 67 | border: 2px solid #D4D4D4; 68 | background: #00497E; 69 | color: #FFFFFF; 70 | padding: 8px 15px; 71 | border-bottom: none; 72 | display: inline-block; 73 | margin: 10px 0px 0px 0px; 74 | } 75 | 76 | .help-page .sample-content { 77 | display: block; 78 | border-width: 0; 79 | padding: 15px 20px; 80 | background: #FFFFFF; 81 | border: 2px solid #D4D4D4; 82 | margin: 0px 0px 10px 0px; 83 | } 84 | 85 | .help-page .api-name { 86 | width: 40%; 87 | } 88 | 89 | .help-page .api-documentation { 90 | width: 60%; 91 | } 92 | 93 | .help-page .parameter-name { 94 | width: 20%; 95 | } 96 | 97 | .help-page .parameter-documentation { 98 | width: 40%; 99 | } 100 | 101 | .help-page .parameter-type { 102 | width: 20%; 103 | } 104 | 105 | .help-page .parameter-annotations { 106 | width: 20%; 107 | } 108 | 109 | .help-page h1, 110 | .help-page .h1 { 111 | font-size: 36px; 112 | line-height: normal; 113 | } 114 | 115 | .help-page h2, 116 | .help-page .h2 { 117 | font-size: 24px; 118 | } 119 | 120 | .help-page h3, 121 | .help-page .h3 { 122 | font-size: 20px; 123 | } 124 | 125 | #body.help-page { 126 | font-size: 14px; 127 | line-height: 143%; 128 | color: #333; 129 | } 130 | 131 | .help-page a { 132 | color: #0000EE; 133 | text-decoration: none; 134 | } 135 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/App_Start/OpenIdConnectCachingSecurityTokenProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Protocols; 2 | using Microsoft.IdentityModel.Protocols.OpenIdConnect; 3 | using Microsoft.IdentityModel.Tokens; 4 | using Microsoft.Owin.Security.Jwt; 5 | using System.Collections.Generic; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace Office_Add_in_ASPNET_SSO_WebAPI.App_Start 10 | { 11 | // This class is necessary because the OAuthBearer Middleware does not leverage 12 | // the OpenID Connect metadata endpoint exposed by the STS by default. 13 | public class OpenIdConnectCachingSecurityTokenProvider : IIssuerSecurityKeyProvider 14 | { 15 | public Microsoft.IdentityModel.Protocols.ConfigurationManager _configManager; 16 | private string _issuer; 17 | private IEnumerable _keys; 18 | private readonly string _metadataEndpoint; 19 | 20 | private readonly ReaderWriterLockSlim _synclock = new ReaderWriterLockSlim(); 21 | 22 | public OpenIdConnectCachingSecurityTokenProvider(string metadataEndpoint) 23 | { 24 | _metadataEndpoint = metadataEndpoint; 25 | _configManager = new ConfigurationManager(metadataEndpoint, new OpenIdConnectConfigurationRetriever()); 26 | 27 | RetrieveMetadata(); 28 | } 29 | 30 | /// 31 | /// Gets the issuer the credentials are for. 32 | /// 33 | /// 34 | /// The issuer the credentials are for. 35 | /// 36 | public string Issuer 37 | { 38 | get 39 | { 40 | RetrieveMetadata(); 41 | _synclock.EnterReadLock(); 42 | try 43 | { 44 | return _issuer; 45 | } 46 | finally 47 | { 48 | _synclock.ExitReadLock(); 49 | } 50 | } 51 | } 52 | 53 | /// 54 | /// Gets all known security keys. 55 | /// 56 | /// 57 | /// All known security keys. 58 | /// 59 | public IEnumerable SecurityKeys 60 | { 61 | get 62 | { 63 | RetrieveMetadata(); 64 | _synclock.EnterReadLock(); 65 | try 66 | { 67 | return _keys; 68 | } 69 | finally 70 | { 71 | _synclock.ExitReadLock(); 72 | } 73 | } 74 | } 75 | 76 | private void RetrieveMetadata() 77 | { 78 | _synclock.EnterWriteLock(); 79 | try 80 | { 81 | OpenIdConnectConfiguration config = Task.Run(_configManager.GetConfigurationAsync).Result; 82 | _issuer = config.Issuer; 83 | _keys = config.SigningKeys; 84 | } 85 | finally 86 | { 87 | _synclock.ExitWriteLock(); 88 | } 89 | } 90 | } 91 | } 92 | 93 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Scripts/HomeES6.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo. 2 | 3 | /* 4 | This file provides functions to get ask the Office host to get an access token to the add-in 5 | and to pass that token to the server to get Microsoft Graph data. 6 | */ 7 | 8 | // To support IE (which uses ES5), we have to create a Promise object for the global context. 9 | if (!window.Promise) { 10 | window.Promise = Office.Promise; 11 | } 12 | 13 | Office.initialize = function (reason) { 14 | 15 | $(document).ready(function () { 16 | $('#getGraphDataButton').click(getGraphData); 17 | }); 18 | }; 19 | 20 | 21 | 22 | 23 | // Displays the data, assumed to be an array. 24 | function showResult(data) { 25 | 26 | // Use jQuery text() method which automatically encodes values that are passed to it, 27 | // in order to protect against injection attacks. 28 | $.each(data, function (i) { 29 | var li = $('
  • ').addClass('ms-ListItem').appendTo($('#file-list')); 30 | var outerSpan = $('').addClass('ms-ListItem-secondaryText').appendTo(li); 31 | $('').addClass('ms-fontColor-themePrimary').appendTo(outerSpan).text(data[i]); 32 | }); 33 | } 34 | 35 | function logError(result) { 36 | console.log("Status: " + result.status); 37 | console.log("Code: " + result.error.code); 38 | console.log("Name: " + result.error.name); 39 | console.log("Message: " + result.error.message); 40 | } 41 | 42 | // Dialog API 43 | 44 | var loginDialog; 45 | var redirectTo = "/files/index"; 46 | 47 | function dialogFallback() { 48 | 49 | var url = "/azureadauth/login"; 50 | showLoginPopup(url); 51 | } 52 | 53 | // This handler responds to the success or failure message that the pop-up dialog receives from the identity provider 54 | // and access token provider. 55 | function processMessage(arg) { 56 | 57 | console.log("Message received in processMessage: " + JSON.stringify(arg)); 58 | let message = JSON.parse(arg.message); 59 | 60 | if (message.status === "success") { 61 | // We now have a valid access token. 62 | loginDialog.close(); 63 | getData("/api/files", message.accessToken); 64 | } else { 65 | // Something went wrong with authentication or the authorization of the web application. 66 | loginDialog.close(); 67 | showResult(["Unable to successfully authenticate user or authorize application. Error is: " + message.error]); 68 | } 69 | } 70 | 71 | // Use the Office dialog API to open a pop-up and display the sign-in page for the identity provider. 72 | function showLoginPopup(url) { 73 | var fullUrl = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '') + url; 74 | 75 | // height and width are percentages of the size of the parent Office application, e.g., PowerPoint, Excel, Word, etc. 76 | Office.context.ui.displayDialogAsync(fullUrl, 77 | { height: 60, width: 30 }, function (result) { 78 | console.log("Dialog has initialized. Wiring up events"); 79 | loginDialog = result.value; 80 | loginDialog.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogMessageReceived, processMessage); 81 | }); 82 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/App_Start/OpenIdConnectCachingSecurityTokenProvider.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.IdentityModel.Protocols; 2 | using Microsoft.IdentityModel.Protocols.OpenIdConnect; 3 | using Microsoft.IdentityModel.Tokens; 4 | using Microsoft.Owin.Security.Jwt; 5 | using System.Collections.Generic; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | namespace Office_Add_in_ASPNET_SSO_WebAPI.App_Start 10 | { 11 | // This class is necessary because the OAuthBearer Middleware does not leverage 12 | // the OpenID Connect metadata endpoint exposed by the STS by default. 13 | public class OpenIdConnectCachingSecurityTokenProvider : IIssuerSecurityKeyProvider 14 | { 15 | public Microsoft.IdentityModel.Protocols.ConfigurationManager _configManager; 16 | private string _issuer; 17 | private IEnumerable _keys; 18 | private readonly string _metadataEndpoint; 19 | 20 | private readonly ReaderWriterLockSlim _synclock = new ReaderWriterLockSlim(); 21 | 22 | public OpenIdConnectCachingSecurityTokenProvider(string metadataEndpoint) 23 | { 24 | _metadataEndpoint = metadataEndpoint; 25 | _configManager = new ConfigurationManager(metadataEndpoint, new OpenIdConnectConfigurationRetriever()); 26 | 27 | RetrieveMetadata(); 28 | } 29 | 30 | /// 31 | /// Gets the issuer the credentials are for. 32 | /// 33 | /// 34 | /// The issuer the credentials are for. 35 | /// 36 | public string Issuer 37 | { 38 | get 39 | { 40 | RetrieveMetadata(); 41 | _synclock.EnterReadLock(); 42 | try 43 | { 44 | return _issuer; 45 | } 46 | finally 47 | { 48 | _synclock.ExitReadLock(); 49 | } 50 | } 51 | } 52 | 53 | /// 54 | /// Gets all known security keys. 55 | /// 56 | /// 57 | /// All known security keys. 58 | /// 59 | public IEnumerable SecurityKeys 60 | { 61 | get 62 | { 63 | RetrieveMetadata(); 64 | _synclock.EnterReadLock(); 65 | try 66 | { 67 | return _keys; 68 | } 69 | finally 70 | { 71 | _synclock.ExitReadLock(); 72 | } 73 | } 74 | } 75 | 76 | private void RetrieveMetadata() 77 | { 78 | _synclock.EnterWriteLock(); 79 | try 80 | { 81 | OpenIdConnectConfiguration config = Task.Run(_configManager.GetConfigurationAsync).Result; 82 | _issuer = config.Issuer; 83 | _keys = config.SigningKeys; 84 | } 85 | finally 86 | { 87 | _synclock.ExitWriteLock(); 88 | } 89 | } 90 | } 91 | } 92 | 93 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Content/OfficeThemes.css: -------------------------------------------------------------------------------- 1 | /* The following classes describe the common theme information for office documents */ 2 | 3 | 4 | 5 | /* Basic Font and Background Colors for text */ 6 | .office-docTheme-primary-fontColor { color:#000000; } 7 | .office-docTheme-primary-bgColor { background-color:#ffffff; } 8 | .office-docTheme-secondary-fontColor { color: #000000; } 9 | .office-docTheme-secondary-bgColor { background-color: #ffffff; } 10 | 11 | 12 | /* Accent color definitions for fonts */ 13 | .office-contentAccent1-color { color:#5b9bd5; } 14 | .office-contentAccent2-color { color:#ed7d31; } 15 | .office-contentAccent3-color { color:#a5a5a5; } 16 | .office-contentAccent4-color { color:#ffc000; } 17 | .office-contentAccent5-color { color:#4472c4; } 18 | .office-contentAccent6-color { color:#70ad47; } 19 | 20 | /* Accent color for backgrounds */ 21 | .office-contentAccent1-bgColor { background-color:#5b9bd5; } 22 | .office-contentAccent2-bgColor { background-color:#ed7d31; } 23 | .office-contentAccent3-bgColor { background-color:#a5a5a5; } 24 | .office-contentAccent4-bgColor { background-color:#ffc000; } 25 | .office-contentAccent5-bgColor { background-color:#4472c4; } 26 | .office-contentAccent6-bgColor { background-color:#70ad47; } 27 | 28 | /* Accent color for borders */ 29 | .office-contentAccent1-borderColor { border-color:#5b9bd5; } 30 | .office-contentAccent2-borderColor { border-color:#ed7d31; } 31 | .office-contentAccent3-borderColor { border-color:#a5a5a5; } 32 | .office-contentAccent4-borderColor { border-color:#ffc000; } 33 | .office-contentAccent5-borderColor { border-color:#4472c4; } 34 | .office-contentAccent6-borderColor { border-color:#70ad47; } 35 | 36 | /* links */ 37 | .office-a {color: #0563c1; } 38 | .office-a:visited { color: #954f72; } 39 | 40 | /* Body Fonts */ 41 | .office-bodyFont-eastAsian { } /* East Asian name of the Font */ 42 | .office-bodyFont-latin { font-family:"Calibri"; } /* Latin name of the Font */ 43 | .office-bodyFont-script { } /* Script name of the Font */ 44 | .office-bodyFont-localized { font-family:"Calibri"; } /* Localized name of the Font. contains the default font name according to the culture currently used in Office */ 45 | 46 | /* Headers Font */ 47 | .office-headerFont-eastAsian { } 48 | .office-headerFont-latin { font-family:"Calibri Light"; } 49 | .office-headerFont-script { } 50 | .office-headerFont-localized { font-family:"Calibri Light"; } 51 | 52 | 53 | 54 | /* The following classes define the Office themes. This classes make sense for the taskpane apps */ 55 | 56 | /* Basic Font and Background Colors for PPT */ 57 | .office-officeTheme-primary-fontColor { color:#b83b1d; } 58 | .office-officeTheme-primary-bgColor { background-color:#dedede; } 59 | .office-officeTheme-secondary-fontColor { color:#262626; } 60 | .office-officeTheme-secondary-bgColor { background-color:#ffffff; } 61 | 62 | /* Basic Font and Background Colors for Outlook Web Access */ 63 | /* remove comments and delete other apps officeTheme classes to get OWA defaults 64 | .office-officeTheme-primary-fontColor { color:#ea4400; } 65 | .office-officeTheme-primary-bgColor { background-color:#ffffff; } 66 | .office-officeTheme-secondary-fontColor { color:#ffffff; } 67 | .office-officeTheme-secondary-bgColor { background-color:#ea4400; } 68 | */ -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Content/OfficeThemes.css: -------------------------------------------------------------------------------- 1 | /* The following classes describe the common theme information for office documents */ 2 | 3 | 4 | 5 | /* Basic Font and Background Colors for text */ 6 | .office-docTheme-primary-fontColor { color:#000000; } 7 | .office-docTheme-primary-bgColor { background-color:#ffffff; } 8 | .office-docTheme-secondary-fontColor { color: #000000; } 9 | .office-docTheme-secondary-bgColor { background-color: #ffffff; } 10 | 11 | 12 | /* Accent color definitions for fonts */ 13 | .office-contentAccent1-color { color:#5b9bd5; } 14 | .office-contentAccent2-color { color:#ed7d31; } 15 | .office-contentAccent3-color { color:#a5a5a5; } 16 | .office-contentAccent4-color { color:#ffc000; } 17 | .office-contentAccent5-color { color:#4472c4; } 18 | .office-contentAccent6-color { color:#70ad47; } 19 | 20 | /* Accent color for backgrounds */ 21 | .office-contentAccent1-bgColor { background-color:#5b9bd5; } 22 | .office-contentAccent2-bgColor { background-color:#ed7d31; } 23 | .office-contentAccent3-bgColor { background-color:#a5a5a5; } 24 | .office-contentAccent4-bgColor { background-color:#ffc000; } 25 | .office-contentAccent5-bgColor { background-color:#4472c4; } 26 | .office-contentAccent6-bgColor { background-color:#70ad47; } 27 | 28 | /* Accent color for borders */ 29 | .office-contentAccent1-borderColor { border-color:#5b9bd5; } 30 | .office-contentAccent2-borderColor { border-color:#ed7d31; } 31 | .office-contentAccent3-borderColor { border-color:#a5a5a5; } 32 | .office-contentAccent4-borderColor { border-color:#ffc000; } 33 | .office-contentAccent5-borderColor { border-color:#4472c4; } 34 | .office-contentAccent6-borderColor { border-color:#70ad47; } 35 | 36 | /* links */ 37 | .office-a {color: #0563c1; } 38 | .office-a:visited { color: #954f72; } 39 | 40 | /* Body Fonts */ 41 | .office-bodyFont-eastAsian { } /* East Asian name of the Font */ 42 | .office-bodyFont-latin { font-family:"Calibri"; } /* Latin name of the Font */ 43 | .office-bodyFont-script { } /* Script name of the Font */ 44 | .office-bodyFont-localized { font-family:"Calibri"; } /* Localized name of the Font. contains the default font name according to the culture currently used in Office */ 45 | 46 | /* Headers Font */ 47 | .office-headerFont-eastAsian { } 48 | .office-headerFont-latin { font-family:"Calibri Light"; } 49 | .office-headerFont-script { } 50 | .office-headerFont-localized { font-family:"Calibri Light"; } 51 | 52 | 53 | 54 | /* The following classes define the Office themes. This classes make sense for the taskpane apps */ 55 | 56 | /* Basic Font and Background Colors for PPT */ 57 | .office-officeTheme-primary-fontColor { color:#b83b1d; } 58 | .office-officeTheme-primary-bgColor { background-color:#dedede; } 59 | .office-officeTheme-secondary-fontColor { color:#262626; } 60 | .office-officeTheme-secondary-bgColor { background-color:#ffffff; } 61 | 62 | /* Basic Font and Background Colors for Outlook Web Access */ 63 | /* remove comments and delete other apps officeTheme classes to get OWA defaults 64 | .office-officeTheme-primary-fontColor { color:#ea4400; } 65 | .office-officeTheme-primary-bgColor { background-color:#ffffff; } 66 | .office-officeTheme-secondary-fontColor { color:#ffffff; } 67 | .office-officeTheme-secondary-bgColor { background-color:#ea4400; } 68 | */ -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Helpers/GraphApiHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the root of the project. 2 | 3 | /* 4 | This file provides URLs to help get Microsoft Graph data. 5 | */ 6 | 7 | using System; 8 | using System.Net; 9 | using System.Net.Http; 10 | using System.Threading.Tasks; 11 | using System.Collections.Generic; 12 | using Office_Add_in_ASPNET_SSO_WebAPI.Models; 13 | using System.Web.Http; 14 | 15 | 16 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Helpers 17 | { 18 | /// 19 | /// Provides methods and strings for Microsoft Graph-specific endpoints. 20 | /// 21 | internal static class GraphApiHelper 22 | { 23 | // Microsoft Graph-related base URLs 24 | internal static string GetFilesUrl = @"https://graph.microsoft.com/v1.0/me/drive/root/children"; 25 | 26 | // The selectedProperties parameter is a query parameter that will be added 27 | // to the Microsoft Graph REST API URL. If any part of it comes from user input, 28 | // be sure that it is sanitized so that it cannot be used in 29 | // a Response header injection attack. 30 | internal static string GetOneDriveItemNamesUrl(string selectedProperties) 31 | { 32 | // Construct URL for the names of the folders and files. 33 | return GetFilesUrl + selectedProperties; 34 | } 35 | 36 | internal static async Task GetOneDriveFileNames(string accessToken) 37 | { 38 | // Get the names of files and folders in OneDrive by using the Microsoft Graph API. 39 | var fullOneDriveItemsUrl = GetOneDriveItemNamesUrl("?$select=name&$top=10"); 40 | IEnumerable filesResult; 41 | try 42 | { 43 | filesResult = await ODataHelper.GetItems(fullOneDriveItemsUrl, accessToken); 44 | } 45 | catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) 46 | { 47 | return HttpErrorHelper.SendErrorToClient(HttpStatusCode.Unauthorized, e, null); 48 | } 49 | 50 | // Remove excess information from the data and send the data to the client. 51 | List itemNames = new List(); 52 | foreach (OneDriveItem item in filesResult) 53 | { 54 | itemNames.Add(item.Name); 55 | } 56 | 57 | var requestMessage = new HttpRequestMessage(); 58 | requestMessage.SetConfiguration(new HttpConfiguration()); 59 | var response = requestMessage.CreateResponse>(HttpStatusCode.OK, itemNames); 60 | return response; 61 | } 62 | 63 | //internal static HttpResponseMessage SendErrorToClient(HttpStatusCode statusCode, Exception e, string message) 64 | //{ 65 | // HttpError error; 66 | // if (e != null) 67 | // { 68 | // error = new HttpError(e, true); 69 | // } 70 | // else 71 | // { 72 | // error = new HttpError(message); 73 | // } 74 | // var requestMessage = new HttpRequestMessage(); 75 | // var errorMessage = requestMessage.CreateErrorResponse(statusCode, error); 76 | // return errorMessage; 77 | //} 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Helpers/ODataHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the root of the project. 2 | 3 | /* 4 | This file provides functions to help get data from OData endpoints. 5 | */ 6 | 7 | using System.Collections.Generic; 8 | using System.Net.Http; 9 | using System.Net.Http.Headers; 10 | using System.Threading.Tasks; 11 | using Newtonsoft.Json; 12 | using Newtonsoft.Json.Linq; 13 | 14 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Helpers 15 | { 16 | /// 17 | /// Provides methods for accessing OData endpoints. 18 | /// 19 | internal static class ODataHelper 20 | { 21 | /// 22 | /// Gets any JSON array from any OData endpoint that requires an access token. 23 | /// Note: If itemsUrl includes a query parameter and any part of the parameter 24 | /// comes from user input, be sure that it is sanitized so that it cannot be used in 25 | /// a Response header injection attack. 26 | /// 27 | /// The .NET type to which the members of the array will be converted. 28 | /// The URL of the OData endpoint. 29 | /// An OAuth access token. 30 | /// Collection of T items that the caller can cast to any IEnumerable type. 31 | internal static async Task> GetItems(string itemsUrl, string accessToken) 32 | { 33 | dynamic jsonData = await SendRequestWithAccessToken(itemsUrl, accessToken); 34 | 35 | // Convert to .NET class and populate the properties of the model objects, 36 | // and then populate the IEnumerable object and return it. 37 | JArray jsonArray = jsonData.value; 38 | return JsonConvert.DeserializeObject>(jsonArray.ToString()); 39 | } 40 | 41 | /// 42 | /// Sends a request to the specified OData URL with the specified access token. 43 | /// 44 | /// The OData endpoint URL. 45 | /// The access token for the endpoint resource. 46 | /// 47 | internal static async Task SendRequestWithAccessToken(string itemsUrl, string accessToken) 48 | { 49 | dynamic jsonData = null; 50 | 51 | using (var client = new HttpClient()) 52 | { 53 | // Create and send the HTTP Request 54 | using (var request = new HttpRequestMessage(HttpMethod.Get, itemsUrl)) 55 | { 56 | request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); 57 | 58 | using (HttpResponseMessage response = await client.SendAsync(request)) 59 | { 60 | if (response.IsSuccessStatusCode) 61 | { 62 | HttpContent content = response.Content; 63 | string responseContent = await content.ReadAsStringAsync(); 64 | 65 | jsonData = JsonConvert.DeserializeObject(responseContent); 66 | } 67 | } 68 | } 69 | } 70 | return jsonData; 71 | } 72 | } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Helpers/ODataHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the root of the project. 2 | 3 | /* 4 | This file provides functions to help get data from OData endpoints. 5 | */ 6 | 7 | using System.Collections.Generic; 8 | using System.Net.Http; 9 | using System.Net.Http.Headers; 10 | using System.Threading.Tasks; 11 | using Newtonsoft.Json; 12 | using Newtonsoft.Json.Linq; 13 | 14 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Helpers 15 | { 16 | /// 17 | /// Provides methods for accessing OData endpoints. 18 | /// 19 | internal static class ODataHelper 20 | { 21 | /// 22 | /// Gets any JSON array from any OData endpoint that requires an access token. 23 | /// Note: If itemsUrl includes a query parameter and any part of the parameter 24 | /// comes from user input, be sure that it is sanitized so that it cannot be used in 25 | /// a Response header injection attack. 26 | /// 27 | /// The .NET type to which the members of the array will be converted. 28 | /// The URL of the OData endpoint. 29 | /// An OAuth access token. 30 | /// Collection of T items that the caller can cast to any IEnumerable type. 31 | internal static async Task> GetItems(string itemsUrl, string accessToken) 32 | { 33 | dynamic jsonData = await SendRequestWithAccessToken(itemsUrl, accessToken); 34 | 35 | // Convert to .NET class and populate the properties of the model objects, 36 | // and then populate the IEnumerable object and return it. 37 | JArray jsonArray = jsonData.value; 38 | return JsonConvert.DeserializeObject>(jsonArray.ToString()); 39 | } 40 | 41 | /// 42 | /// Sends a request to the specified OData URL with the specified access token. 43 | /// 44 | /// The OData endpoint URL. 45 | /// The access token for the endpoint resource. 46 | /// 47 | internal static async Task SendRequestWithAccessToken(string itemsUrl, string accessToken) 48 | { 49 | dynamic jsonData = null; 50 | 51 | using (var client = new HttpClient()) 52 | { 53 | // Create and send the HTTP Request 54 | using (var request = new HttpRequestMessage(HttpMethod.Get, itemsUrl)) 55 | { 56 | request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); 57 | 58 | using (HttpResponseMessage response = await client.SendAsync(request)) 59 | { 60 | if (response.IsSuccessStatusCode) 61 | { 62 | HttpContent content = response.Content; 63 | string responseContent = await content.ReadAsStringAsync(); 64 | 65 | jsonData = JsonConvert.DeserializeObject(responseContent); 66 | } 67 | } 68 | } 69 | } 70 | return jsonData; 71 | } 72 | } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Controllers/AzureADAuthController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo. 2 | 3 | using Microsoft.Identity.Client; 4 | using Newtonsoft.Json; 5 | using Office_Add_in_ASPNET_SSO_WebAPI.Helpers; 6 | using Office_Add_in_ASPNET_SSO_WebAPI.Models; 7 | using System; 8 | using System.IdentityModel.Tokens; 9 | using System.Linq; 10 | using System.Threading.Tasks; 11 | using System.Web.Mvc; 12 | 13 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Controllers 14 | { 15 | public class AzureADAuthController : Controller 16 | { 17 | // The URL that auth should redirect to after a successful login. 18 | Uri loginRedirectUri => new Uri(Url.Action(nameof(Authorize), "AzureADAuth", null, Request.Url.Scheme)); 19 | 20 | /// 21 | /// Logs the user into Microsoft 365. 22 | /// 23 | /// A redirect to the Microsoft 365 login page. 24 | public async Task Login() 25 | { 26 | if (string.IsNullOrEmpty(Settings.AzureADClientId) || string.IsNullOrEmpty(Settings.AzureADClientSecret)) 27 | { 28 | ViewBag.Message = "Please set your client ID and client secret in the Web.config file"; 29 | return View(); 30 | } 31 | 32 | ConfidentialClientApplicationBuilder clientBuilder = ConfidentialClientApplicationBuilder 33 | .Create(Settings.AzureADClientId) 34 | .WithClientSecret(Settings.AzureADClientSecret); 35 | ; 36 | ConfidentialClientApplication clientApp = (ConfidentialClientApplication)clientBuilder.Build(); 37 | 38 | // Generate the parameterized URL for Azure login. 39 | string[] graphScopes = { "https://graph.microsoft.com/Files.Read.All" }; 40 | var urlBuilder = clientApp.GetAuthorizationRequestUrl(graphScopes); 41 | urlBuilder.WithRedirectUri(loginRedirectUri.ToString()); 42 | urlBuilder.WithAuthority(Settings.AzureADAuthority); 43 | 44 | var authUrl = await urlBuilder.ExecuteAsync(System.Threading.CancellationToken.None); 45 | 46 | // Redirect the browser to the login page, then come back to the Authorize method below. 47 | return Redirect(authUrl.ToString()); 48 | } 49 | 50 | /// 51 | /// Gets IdToken from implicit flow and sends it to main add-in window. 52 | /// 53 | /// The default view. 54 | public async Task Authorize() 55 | { 56 | 57 | ConfidentialClientApplicationBuilder clientBuilder = ConfidentialClientApplicationBuilder.Create(Settings.AzureADClientId); 58 | clientBuilder.WithClientSecret(Settings.AzureADClientSecret); 59 | clientBuilder.WithRedirectUri(loginRedirectUri.ToString()); 60 | clientBuilder.WithAuthority(Settings.AzureADAuthority); 61 | 62 | ConfidentialClientApplication clientApp = (ConfidentialClientApplication)clientBuilder.Build(); 63 | string[] graphScopes = { "Files.Read.All" }; 64 | 65 | // Get and save the token. 66 | var authResultBuilder = clientApp.AcquireTokenByAuthorizationCode( 67 | graphScopes, 68 | Request.Params["code"] // The auth 'code' parameter from the Azure redirect. 69 | ); 70 | 71 | try 72 | { 73 | var authResult = await authResultBuilder.ExecuteAsync(); 74 | ViewBag.AccessToken = authResult.AccessToken; 75 | } 76 | catch (Exception e) 77 | { 78 | ViewBag.Error = e.Message; 79 | } 80 | 81 | return View(); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Controllers/AzureADAuthController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license in the root of the repo. 2 | 3 | using Microsoft.Identity.Client; 4 | using Newtonsoft.Json; 5 | using Office_Add_in_ASPNET_SSO_WebAPI.Helpers; 6 | using Office_Add_in_ASPNET_SSO_WebAPI.Models; 7 | using System; 8 | using System.IdentityModel.Tokens; 9 | using System.Linq; 10 | using System.Threading.Tasks; 11 | using System.Web.Mvc; 12 | 13 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Controllers 14 | { 15 | public class AzureADAuthController : Controller 16 | { 17 | // The URL that auth should redirect to after a successful login. 18 | Uri loginRedirectUri => new Uri(Url.Action(nameof(Authorize), "AzureADAuth", null, Request.Url.Scheme)); 19 | 20 | /// 21 | /// Logs the user into Microsoft 365. 22 | /// 23 | /// A redirect to the Microsoft 365 login page. 24 | public async Task Login() 25 | { 26 | if (string.IsNullOrEmpty(Settings.AzureADClientId) || string.IsNullOrEmpty(Settings.AzureADClientSecret)) 27 | { 28 | ViewBag.Message = "Please set your client ID and client secret in the Web.config file"; 29 | return View(); 30 | } 31 | 32 | ConfidentialClientApplicationBuilder clientBuilder = ConfidentialClientApplicationBuilder 33 | .Create(Settings.AzureADClientId) 34 | .WithClientSecret(Settings.AzureADClientSecret); 35 | ; 36 | ConfidentialClientApplication clientApp = (ConfidentialClientApplication)clientBuilder.Build(); 37 | 38 | // Generate the parameterized URL for Azure login. 39 | string[] graphScopes = { "https://graph.microsoft.com/Files.Read.All" }; 40 | var urlBuilder = clientApp.GetAuthorizationRequestUrl(graphScopes); 41 | urlBuilder.WithRedirectUri(loginRedirectUri.ToString()); 42 | urlBuilder.WithAuthority(Settings.AzureADAuthority); 43 | 44 | var authUrl = await urlBuilder.ExecuteAsync(System.Threading.CancellationToken.None); 45 | 46 | // Redirect the browser to the login page, then come back to the Authorize method below. 47 | return Redirect(authUrl.ToString()); 48 | } 49 | 50 | /// 51 | /// Gets IdToken from implicit flow and sends it to main add-in window. 52 | /// 53 | /// The default view. 54 | public async Task Authorize() 55 | { 56 | 57 | ConfidentialClientApplicationBuilder clientBuilder = ConfidentialClientApplicationBuilder.Create(Settings.AzureADClientId); 58 | clientBuilder.WithClientSecret(Settings.AzureADClientSecret); 59 | clientBuilder.WithRedirectUri(loginRedirectUri.ToString()); 60 | clientBuilder.WithAuthority(Settings.AzureADAuthority); 61 | 62 | ConfidentialClientApplication clientApp = (ConfidentialClientApplication)clientBuilder.Build(); 63 | string[] graphScopes = { "Files.Read.All" }; 64 | 65 | // Get and save the token. 66 | var authResultBuilder = clientApp.AcquireTokenByAuthorizationCode( 67 | graphScopes, 68 | Request.Params["code"] // The auth 'code' parameter from the Azure redirect. 69 | ); 70 | 71 | try 72 | { 73 | var authResult = await authResultBuilder.ExecuteAsync(); 74 | ViewBag.AccessToken = authResult.AccessToken; 75 | } 76 | catch (Exception e) 77 | { 78 | ViewBag.Error = e.Message; 79 | } 80 | 81 | return View(); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Models/HelpPageApiModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | using System.Net.Http.Headers; 4 | using System.Web.Http.Description; 5 | using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions; 6 | 7 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Models 8 | { 9 | /// 10 | /// The model that represents an API displayed on the help page. 11 | /// 12 | public class HelpPageApiModel 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public HelpPageApiModel() 18 | { 19 | UriParameters = new Collection(); 20 | SampleRequests = new Dictionary(); 21 | SampleResponses = new Dictionary(); 22 | ErrorMessages = new Collection(); 23 | } 24 | 25 | /// 26 | /// Gets or sets the that describes the API. 27 | /// 28 | public ApiDescription ApiDescription { get; set; } 29 | 30 | /// 31 | /// Gets or sets the collection that describes the URI parameters for the API. 32 | /// 33 | public Collection UriParameters { get; private set; } 34 | 35 | /// 36 | /// Gets or sets the documentation for the request. 37 | /// 38 | public string RequestDocumentation { get; set; } 39 | 40 | /// 41 | /// Gets or sets the that describes the request body. 42 | /// 43 | public ModelDescription RequestModelDescription { get; set; } 44 | 45 | /// 46 | /// Gets the request body parameter descriptions. 47 | /// 48 | public IList RequestBodyParameters 49 | { 50 | get 51 | { 52 | return GetParameterDescriptions(RequestModelDescription); 53 | } 54 | } 55 | 56 | /// 57 | /// Gets or sets the that describes the resource. 58 | /// 59 | public ModelDescription ResourceDescription { get; set; } 60 | 61 | /// 62 | /// Gets the resource property descriptions. 63 | /// 64 | public IList ResourceProperties 65 | { 66 | get 67 | { 68 | return GetParameterDescriptions(ResourceDescription); 69 | } 70 | } 71 | 72 | /// 73 | /// Gets the sample requests associated with the API. 74 | /// 75 | public IDictionary SampleRequests { get; private set; } 76 | 77 | /// 78 | /// Gets the sample responses associated with the API. 79 | /// 80 | public IDictionary SampleResponses { get; private set; } 81 | 82 | /// 83 | /// Gets the error messages associated with this model. 84 | /// 85 | public Collection ErrorMessages { get; private set; } 86 | 87 | private static IList GetParameterDescriptions(ModelDescription modelDescription) 88 | { 89 | ComplexTypeModelDescription complexTypeModelDescription = modelDescription as ComplexTypeModelDescription; 90 | if (complexTypeModelDescription != null) 91 | { 92 | return complexTypeModelDescription.Properties; 93 | } 94 | 95 | CollectionModelDescription collectionModelDescription = modelDescription as CollectionModelDescription; 96 | if (collectionModelDescription != null) 97 | { 98 | complexTypeModelDescription = collectionModelDescription.ElementDescription as ComplexTypeModelDescription; 99 | if (complexTypeModelDescription != null) 100 | { 101 | return complexTypeModelDescription.Properties; 102 | } 103 | } 104 | 105 | return null; 106 | } 107 | } 108 | } -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Areas/HelpPage/Models/HelpPageApiModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.ObjectModel; 3 | using System.Net.Http.Headers; 4 | using System.Web.Http.Description; 5 | using Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.ModelDescriptions; 6 | 7 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Areas.HelpPage.Models 8 | { 9 | /// 10 | /// The model that represents an API displayed on the help page. 11 | /// 12 | public class HelpPageApiModel 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | public HelpPageApiModel() 18 | { 19 | UriParameters = new Collection(); 20 | SampleRequests = new Dictionary(); 21 | SampleResponses = new Dictionary(); 22 | ErrorMessages = new Collection(); 23 | } 24 | 25 | /// 26 | /// Gets or sets the that describes the API. 27 | /// 28 | public ApiDescription ApiDescription { get; set; } 29 | 30 | /// 31 | /// Gets or sets the collection that describes the URI parameters for the API. 32 | /// 33 | public Collection UriParameters { get; private set; } 34 | 35 | /// 36 | /// Gets or sets the documentation for the request. 37 | /// 38 | public string RequestDocumentation { get; set; } 39 | 40 | /// 41 | /// Gets or sets the that describes the request body. 42 | /// 43 | public ModelDescription RequestModelDescription { get; set; } 44 | 45 | /// 46 | /// Gets the request body parameter descriptions. 47 | /// 48 | public IList RequestBodyParameters 49 | { 50 | get 51 | { 52 | return GetParameterDescriptions(RequestModelDescription); 53 | } 54 | } 55 | 56 | /// 57 | /// Gets or sets the that describes the resource. 58 | /// 59 | public ModelDescription ResourceDescription { get; set; } 60 | 61 | /// 62 | /// Gets the resource property descriptions. 63 | /// 64 | public IList ResourceProperties 65 | { 66 | get 67 | { 68 | return GetParameterDescriptions(ResourceDescription); 69 | } 70 | } 71 | 72 | /// 73 | /// Gets the sample requests associated with the API. 74 | /// 75 | public IDictionary SampleRequests { get; private set; } 76 | 77 | /// 78 | /// Gets the sample responses associated with the API. 79 | /// 80 | public IDictionary SampleResponses { get; private set; } 81 | 82 | /// 83 | /// Gets the error messages associated with this model. 84 | /// 85 | public Collection ErrorMessages { get; private set; } 86 | 87 | private static IList GetParameterDescriptions(ModelDescription modelDescription) 88 | { 89 | ComplexTypeModelDescription complexTypeModelDescription = modelDescription as ComplexTypeModelDescription; 90 | if (complexTypeModelDescription != null) 91 | { 92 | return complexTypeModelDescription.Properties; 93 | } 94 | 95 | CollectionModelDescription collectionModelDescription = modelDescription as CollectionModelDescription; 96 | if (collectionModelDescription != null) 97 | { 98 | complexTypeModelDescription = collectionModelDescription.ElementDescription as ComplexTypeModelDescription; 99 | if (complexTypeModelDescription != null) 100 | { 101 | return complexTypeModelDescription.Properties; 102 | } 103 | } 104 | 105 | return null; 106 | } 107 | } 108 | } -------------------------------------------------------------------------------- /Before/Office-Add-in-ASPNET-SSO-WebAPI/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /Complete/Office-Add-in-ASPNET-SSO-WebAPI/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the root of the repo. 2 | 3 | /* 4 | This file provides controller methods to get data from MS Graph. 5 | */ 6 | 7 | using Microsoft.Identity.Client; 8 | using System.Configuration; 9 | using System.Linq; 10 | using System.Security.Claims; 11 | using System.Threading.Tasks; 12 | using System.Web.Http; 13 | using System; 14 | using System.Net; 15 | using System.Net.Http; 16 | using Office_Add_in_ASPNET_SSO_WebAPI.Helpers; 17 | 18 | namespace Office_Add_in_ASPNET_SSO_WebAPI.Controllers 19 | { 20 | [Authorize] 21 | public class ValuesController : ApiController 22 | { 23 | // GET api/values 24 | public async Task Get() 25 | { 26 | // OWIN middleware validated the audience, but the scope must also be validated. It must contain "access_as_user". 27 | string[] addinScopes = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/scope").Value.Split(' '); 28 | if (!(addinScopes.Contains("access_as_user"))) 29 | { 30 | return HttpErrorHelper.SendErrorToClient(HttpStatusCode.Unauthorized, null, "Missing access_as_user."); 31 | } 32 | 33 | // Assemble all the information that is needed to get a token for Microsoft Graph using the "on behalf of" flow. 34 | // Beginning with MSAL.NET 3.x.x and later, the bootstrapContext is just the bootstrap token itself. 35 | string bootstrapContext = ClaimsPrincipal.Current.Identities.First().BootstrapContext.ToString(); 36 | UserAssertion userAssertion = new UserAssertion(bootstrapContext); 37 | 38 | var cca = ConfidentialClientApplicationBuilder.Create(ConfigurationManager.AppSettings["ida:ClientID"]) 39 | .WithRedirectUri(ConfigurationManager.AppSettings["ida:Domain"]) 40 | .WithClientSecret(ConfigurationManager.AppSettings["ida:Password"]) 41 | .WithAuthority(ConfigurationManager.AppSettings["ida:Authority"]) 42 | .Build(); 43 | 44 | // MSAL.NET adds the profile itself. It will throw an error if you add it redundantly here. 45 | string[] graphScopes = { "https://graph.microsoft.com/Files.Read.All" }; 46 | 47 | // Get the access token for Microsoft Graph. 48 | AcquireTokenOnBehalfOfParameterBuilder parameterBuilder = null; 49 | AuthenticationResult authResult = null; 50 | try 51 | { 52 | parameterBuilder = cca.AcquireTokenOnBehalfOf(graphScopes, userAssertion); 53 | authResult = await parameterBuilder.ExecuteAsync(); 54 | } 55 | catch (MsalServiceException e) 56 | { 57 | // Handle request for multi-factor authentication. 58 | if (e.Message.StartsWith("AADSTS50076")) 59 | { 60 | string responseMessage = String.Format("{{\"AADError\":\"AADSTS50076\",\"Claims\":{0}}}", e.Claims); 61 | return HttpErrorHelper.SendErrorToClient(HttpStatusCode.Forbidden, null, responseMessage); 62 | // The client should recall the getAccessToken function and pass the claims string as the 63 | // authChallenge value in the function's Options parameter. 64 | } 65 | 66 | // Handle lack of consent (AADSTS65001) and invalid scope (permission). 67 | if ((e.Message.StartsWith("AADSTS65001")) || (e.Message.StartsWith("AADSTS70011: The provided value for the input parameter 'scope' is not valid."))) 68 | { 69 | return HttpErrorHelper.SendErrorToClient(HttpStatusCode.Forbidden, e, null); 70 | } 71 | 72 | // Handle all other MsalServiceExceptions. 73 | else 74 | { 75 | throw e; 76 | } 77 | } 78 | 79 | return await GraphApiHelper.GetOneDriveFileNames(authResult.AccessToken); 80 | } 81 | 82 | // GET api/values/5 83 | public string Get(int id) 84 | { 85 | return "value"; 86 | } 87 | 88 | // POST api/values 89 | public void Post([FromBody]string value) 90 | { 91 | } 92 | 93 | // PUT api/values/5 94 | public void Put(int id, [FromBody]string value) 95 | { 96 | } 97 | 98 | // DELETE api/values/5 99 | public void Delete(int id) 100 | { 101 | } 102 | } 103 | } 104 | --------------------------------------------------------------------------------