Skip to content

Commit 405bc0a

Browse files
author
Kalyan Krishna
committed
more fixes
1 parent e8cb0c3 commit 405bc0a

11 files changed

Lines changed: 78 additions & 70 deletions

File tree

AppCreationScripts/Cleanup.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ param(
77
[string] $azureEnvironmentName
88
)
99

10+
#Requires -Modules AzureAD
11+
12+
1013
if ($null -eq (Get-Module -ListAvailable -Name "AzureAD")) {
1114
Install-Module "AzureAD" -Scope CurrentUser
1215
}

AppCreationScripts/Configure.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ param(
77
[string] $azureEnvironmentName
88
)
99

10+
#Requires -Modules AzureAD
11+
1012
<#
1113
This script creates the Azure AD applications needed for this sample and updates the configuration files
1214
for the visual Studio projects from the data in the Azure AD applications.
@@ -185,9 +187,10 @@ Function ConfigureApplications
185187
Write-Host "Creating the AAD application (TodoListService (appmodelv2-nativeclient-dotnet))"
186188
# create the application
187189
$serviceAadApplication = New-AzureADApplication -DisplayName "TodoListService (appmodelv2-nativeclient-dotnet)" `
188-
-HomePage "https://localhost:44351/" `
190+
-HomePage "https://localhost:44321/" `
189191
-AvailableToOtherTenants $True `
190192
-PublicClient $False
193+
191194
$serviceIdentifierUri = 'api://'+$serviceAadApplication.AppId
192195
Set-AzureADApplication -ObjectId $serviceAadApplication.ObjectId -IdentifierUris $serviceIdentifierUri
193196

AppCreationScripts/sample.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"Id": "service",
1717
"Name": "TodoListService (appmodelv2-nativeclient-dotnet)",
1818
"Kind": "WebApi",
19-
"HomePage": "https://localhost:44351/",
19+
"HomePage": "https://localhost:44321/",
2020
"Audience": "AzureADandPersonalMicrosoftAccount",
2121
"ManualSteps": [
2222
{

README.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,21 @@ services: active-directory
33
platforms: dotnet
44
author: jmprieur
55
level: 200
6-
client: Windows Desktop WPF
7-
service: ASP.NET Web API
8-
endpoint: AAD V2
6+
client: .NET Desktop (WPF)
7+
service: ASP.NET Core Web API
8+
endpoint: Microsoft identity platform
9+
page_type: sample
10+
languages:
11+
- csharp
12+
products:
13+
- azure
14+
- azure-active-directory
15+
- dotnet
16+
- office-ms-graph
17+
description: "This sample demonstrates a .NET Desktop (WPF) application calling a ASP.NET Web API that is secured using Microsoft identity platform"
918
---
1019

11-
# Calling an ASP.NET Web API protected by the Azure AD V2 endpoint from an Windows Desktop (WPF) application
20+
# Calling an ASP.NET Web API protected by Microsoft identity platform endpoint from an Windows Desktop (WPF) application
1221

1322
## About this sample
1423

@@ -93,11 +102,11 @@ As a first step you'll need to:
93102
1. Select **Register** to create the application.
94103
1. In the app's registration screen, find and note the **Application (client) ID**. You use this value in your app's configuration file(s) later in your code.
95104
1. Select **Save** to save your changes.
96-
1. In the app's registration screen, click on the **Expose an API** blade to the left to open the page where you can declare the parameters to expose this app as an Api for which client applications can obtain [access tokens](https://docs.microsoft.com/azure/active-directory/develop/access-tokens) for.
97-
The first thing that we need to do is to declare the unique [resource](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow) URI that the clients will be using to obtain access tokens for this Api. To declare an resource URI, follow the following steps:
105+
1. In the app's registration screen, select the **Expose an API** blade to the left to open the page where you can declare the parameters to expose this app as an API for which client applications can obtain [access tokens](https://docs.microsoft.com/azure/active-directory/develop/access-tokens) for.
106+
The first thing that we need to do is to declare the unique [resource](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow) URI that the clients will be using to obtain access tokens for this API. To declare an resource URI, follow the following steps:
98107
- Click `Set` next to the **Application ID URI** to generate a URI that is unique for this app.
99108
- For this sample, accept the proposed Application ID URI (api://{clientId}) by selecting **Save**.
100-
1. All Apis have to publish a minimum of one [scope](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-authorization-code) for the client's to obtain an access token successfully. To publish a scope, follow the following steps:
109+
1. All APIs have to publish a minimum of one [scope](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-authorization-code) for the client's to obtain an access token successfully. To publish a scope, follow the following steps:
101110
- Select **Add a scope** button open the **Add a scope** screen and Enter the values as indicated below:
102111
- For **Scope name**, use `access_as_user`.
103112
- Select **Admins and users** options for **Who can consent?**
@@ -130,7 +139,7 @@ Open the project in your IDE (like Visual Studio) to configure the code.
130139
- In the **Redirect URIs** | **Suggested Redirect URIs for public clients (mobile, desktop)** section, select **https://login.microsoftonline.com/common/oauth2/nativeclient**
131140

132141
1. Select **Save** to save your changes.
133-
1. In the app's registration screen, click on the **API permissions** blade in the left to open the page where we add access to the Apis that your application needs.
142+
1. In the app's registration screen, click on the **API permissions** blade in the left to open the page where we add access to the APIs that your application needs.
134143
- Click the **Add a permission** button and then,
135144
- Ensure that the **My APIs** tab is selected.
136145
- In the list of APIs, select the API `TodoListService (appmodelv2-nativeclient-dotnet)`.
@@ -146,9 +155,9 @@ Open the project in your IDE (like Visual Studio) to configure the code.
146155
1. Find the app key `ida:Tenant` and replace the existing value with your Azure AD tenant name.
147156
1. Find the app key `ida:ClientId` and replace the existing value with the application ID (clientId) of the `TodoListClient (appmodelv2-nativeclient-dotnet)` application copied from the Azure portal.
148157
1. Find the app key `TodoListServiceScope` and replace the existing value with Scope.
149-
1. Find the app key `TodoListServiceBaseAddress` and replace the existing value with the base address of the TodoListService (appmodelv2-nativeclient-dotnet) project (by default `https://localhost:44351/`).
158+
1. Find the app key `TodoListServiceBaseAddress` and replace the existing value with the base address of the TodoListService (appmodelv2-nativeclient-dotnet) project (by default `https://localhost:44321/`).
150159

151-
### Step 5: Pre-authorize your client application
160+
### Step 4: Pre-authorize your client application
152161

153162
One of the ways to allow users from other directories to access your Web API is by *pre-authorizing* the client applications to access your Web API by adding the Application Ids from client applications in the list of *pre-authorized* applications for your Web API. By adding a pre-authorized client, you will not require user to consent to use your Web API. Follow the steps below to pre-authorize your Web Application::
154163

@@ -158,7 +167,7 @@ One of the ways to allow users from other directories to access your Web API is
158167
1. In the *Authorized scopes* section, select the scope for this Web API `api://<Application ID>/access_as_user`.
159168
1. Press the **Add application** button at the bottom of the page.
160169

161-
### Step 6: Run your project
170+
### Step 5: Run your project
162171

163172
Clean the solution, rebuild the solution, and run it. You might want to go into the solution properties and set both projects as startup projects, with the service project starting first.
164173

@@ -167,7 +176,7 @@ Clean the solution, rebuild the solution, and run it. You might want to go into
167176

168177
## Optional: Restrict sign-in access to your application
169178

170-
By default, when you download this code sample and configure the application to use the Azure Active Directory v2 endpoint following the preceding steps, both personal accounts - like outlook.com, live.com, and others - as well as Work or school accounts from any organizations that are integrated with Azure AD can request tokens and access your Web API.
179+
By default, when you download this code sample and configure the application to use the Microsoft identity platform endpoint following the preceding steps, both personal accounts - like outlook.com, live.com, and others - as well as Work or school accounts from any organizations that are integrated with Azure AD can request tokens and access your Web API.
171180

172181
To restrict who can sign in to your application, use one of the options:
173182

TodoListClient/App.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
55
</startup>
66
<appSettings>
77
<!-- Hostname for the Azure AD instance. {0} will be replaced by the value of ida:Tenant below
@@ -18,7 +18,7 @@
1818
- 'consumers' to sign-in only Microsoft personal accounts
1919
This should be consistent with the audience of users who can sign-in, as specified during the application registration
2020
-->
21-
<add key="ida:Tenant" value="organizations" />
21+
<add key="ida:Tenant" value="common" />
2222
<!--
2323
ClientID (ApplicationID) of your application as registered in the App Registration under Azure Active Directory
2424
in https://portal.azure.com
@@ -31,6 +31,6 @@
3131
clientId of a legacy application, created in the https://portal.azure.com portal.
3232
-->
3333
<add key="TodoListServiceScope" value="api://[Enter the Application Id that you copied from the App Registration Portal.]/access_as_user" />
34-
<add key="TodoListServiceBaseAddress" value="https://localhost:44351/" />
34+
<add key="TodoListServiceBaseAddress" value="https://localhost:44321/" />
3535
</appSettings>
3636
</configuration>

TodoListClient/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TodoListClient/Properties/Settings.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TodoListClient/TodoListClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>TodoListClient</RootNamespace>
1111
<AssemblyName>TodoListClient</AssemblyName>
12-
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1515
<WarningLevel>4</WarningLevel>

TodoListService/TodoListService.csproj

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<AppDesignerFolder>Properties</AppDesignerFolder>
1414
<RootNamespace>TodoListService</RootNamespace>
1515
<AssemblyName>TodoListService</AssemblyName>
16-
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
16+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1717
<MvcBuildViews>false</MvcBuildViews>
1818
<UseIISExpress>true</UseIISExpress>
1919
<IISExpressSSLPort>44321</IISExpressSSLPort>
@@ -43,7 +43,6 @@
4343
</PropertyGroup>
4444
<ItemGroup>
4545
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
46-
<SpecificVersion>False</SpecificVersion>
4746
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
4847
</Reference>
4948
<Reference Include="Microsoft.CSharp" />
@@ -65,11 +64,13 @@
6564
<Reference Include="Microsoft.Owin.Security.OAuth, Version=3.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6665
<HintPath>..\packages\Microsoft.Owin.Security.OAuth.3.1.0\lib\net45\Microsoft.Owin.Security.OAuth.dll</HintPath>
6766
</Reference>
68-
<Reference Include="Newtonsoft.Json">
67+
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
68+
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
69+
</Reference>
70+
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
6971
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
7072
</Reference>
7173
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
72-
<SpecificVersion>False</SpecificVersion>
7374
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
7475
</Reference>
7576
<Reference Include="System" />
@@ -90,6 +91,8 @@
9091
<Reference Include="System.Web.ApplicationServices" />
9192
<Reference Include="System.ComponentModel.DataAnnotations" />
9293
<Reference Include="System.Web.Extensions" />
94+
<Reference Include="System.Web" />
95+
<Reference Include="System.Web.Abstractions" />
9396
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
9497
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll</HintPath>
9598
</Reference>
@@ -103,12 +106,12 @@
103106
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.4\lib\net45\System.Web.Mvc.dll</HintPath>
104107
</Reference>
105108
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
106-
<SpecificVersion>False</SpecificVersion>
107109
<HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
108110
</Reference>
109111
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
110112
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll</HintPath>
111113
</Reference>
114+
<Reference Include="System.Web.Routing" />
112115
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
113116
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll</HintPath>
114117
</Reference>
@@ -118,22 +121,14 @@
118121
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
119122
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
120123
</Reference>
121-
<Reference Include="System.Web" />
122-
<Reference Include="System.Web.Abstractions" />
123-
<Reference Include="System.Web.Routing" />
124124
<Reference Include="System.Xml" />
125125
<Reference Include="System.Configuration" />
126-
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
127-
<Private>True</Private>
128-
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
129-
</Reference>
130126
<Reference Include="System.Net.Http">
131127
</Reference>
132128
<Reference Include="System.Net.Http.WebRequest">
133129
</Reference>
134130
<Reference Include="System.Xml.Linq" />
135131
<Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
136-
<SpecificVersion>False</SpecificVersion>
137132
<HintPath>..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
138133
</Reference>
139134
</ItemGroup>
@@ -190,6 +185,14 @@
190185
<Content Include="favicon.ico" />
191186
<Content Include="fonts\glyphicons-halflings-regular.svg" />
192187
<Content Include="Global.asax" />
188+
<Content Include="fonts\glyphicons-halflings-regular.woff2" />
189+
<Content Include="fonts\glyphicons-halflings-regular.woff" />
190+
<Content Include="fonts\glyphicons-halflings-regular.ttf" />
191+
<Content Include="fonts\glyphicons-halflings-regular.eot" />
192+
<Content Include="Content\bootstrap.min.css.map" />
193+
<Content Include="Content\bootstrap.css.map" />
194+
<Content Include="Content\bootstrap-theme.min.css.map" />
195+
<Content Include="Content\bootstrap-theme.css.map" />
193196
<Content Include="Areas\HelpPage\Views\_ViewStart.cshtml" />
194197
<Content Include="Areas\HelpPage\Views\Web.config" />
195198
<Content Include="Areas\HelpPage\Views\Shared\_Layout.cshtml" />
@@ -210,14 +213,7 @@
210213
<Content Include="Areas\HelpPage\Views\Help\DisplayTemplates\CollectionModelDescription.cshtml" />
211214
<Content Include="Areas\HelpPage\Views\Help\DisplayTemplates\ApiGroup.cshtml" />
212215
<Content Include="Areas\HelpPage\Views\Help\Api.cshtml" />
213-
<Content Include="fonts\glyphicons-halflings-regular.woff2" />
214-
<Content Include="fonts\glyphicons-halflings-regular.woff" />
215-
<Content Include="fonts\glyphicons-halflings-regular.ttf" />
216-
<Content Include="fonts\glyphicons-halflings-regular.eot" />
217-
<Content Include="Content\bootstrap.min.css.map" />
218-
<Content Include="Content\bootstrap.css.map" />
219-
<Content Include="Content\bootstrap-theme.min.css.map" />
220-
<Content Include="Content\bootstrap-theme.css.map" />
216+
<None Include="packages.config" />
221217
<None Include="Scripts\jquery-1.10.2.intellisense.js" />
222218
<None Include="Scripts\jquery-2.1.1.intellisense.js" />
223219
<Content Include="Scripts\bootstrap.js" />
@@ -253,9 +249,6 @@
253249
<Folder Include="Views\TodoList\" />
254250
</ItemGroup>
255251
<ItemGroup>
256-
<Content Include="packages.config">
257-
<SubType>Designer</SubType>
258-
</Content>
259252
<None Include="Project_Readme.html" />
260253
</ItemGroup>
261254
<PropertyGroup>

TodoListService/Web.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</system.Web>
2121
-->
2222
<system.web>
23-
<compilation debug="true" targetFramework="4.6" />
23+
<compilation debug="true" targetFramework="4.7.2" />
2424
<httpRuntime targetFramework="4.5" />
2525
</system.web>
2626
<runtime>

0 commit comments

Comments
 (0)