Skip to content

Commit 199ce0a

Browse files
authored
Merge pull request #3 from AzureADQuickStarts/desktopCallingAnotherV2WebApi
Improving the App.Config to explain all the possibilities
2 parents 1377167 + d8ad0a2 commit 199ce0a

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

TodoListClient/App.config

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@
44
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
55
</startup>
66
<appSettings>
7+
<!-- ida:Client is a GUID representing the Application Id for the TodoListClient app that you copied from
8+
the App Registration Portal (https://apps.dev.microsoft.com) -->
79
<add key="ida:ClientId" value="{Enter the Application Id that you copied from the App Registration Portal.}" />
10+
11+
<!-- todo:Scope is either:
12+
- the same as ida:ClientId, as V2 apps enable several platforms for a same application (a GUID)
13+
- or otherwise the scope of the Web API created with aht App Registration portal, for instance api://[V2-WebApi-AppId]/access_as_user
14+
where [V2-WebApi-AppId] is a GUID representing the Application ID of the Web API.
15+
- or otherwise this can be the scope of a V1 Web API (created with https://portal.azure.com) for instance [V1_WebApi-AppId]/user_impersonation
16+
where [V1-WebApi-AppId] is a GUID representing the Application ID (also named Client ID) of the V1 Web API created in https://portal.azure.com.
17+
In that case (V1 app), the Authority used to build the PubliClientApplication in MainWindow.xaml.cs should be set to
18+
"https://login.microsoftonline.com/organizations/" instead of "https://login.microsoftonline.com/common/"
19+
-->
820
<add key="todo:Scope" value="{Enter the scope of the Web API, as copied from the App Registration Portal, for instance api://[WebApi-AppId]/access_as_user where [WebApi-AppId] is a GUID" />
9-
<!--
10-
Note that the [WebAPI-AppId], which is the Application Id of the called Web API can be the same as the ida:ClientId
11-
as V2 apps enable several platforms for a same application. But this can also be a different applications
12-
-->
21+
1322
<add key="todo:TodoListBaseAddress" value="https://localhost:44321/" />
1423
</appSettings>
1524
</configuration>

TodoListService/App_Start/Startup.Auth.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,17 @@ namespace TodoListService
1313
{
1414
public partial class Startup
1515
{
16-
private static string clientId = ConfigurationManager.AppSettings["ida:Audience"];
16+
private static string audience = ConfigurationManager.AppSettings["ida:Audience"];
1717

1818
public void ConfigureAuth(IAppBuilder app)
1919
{
2020
var tvps = new TokenValidationParameters
2121
{
22-
// In this app, the TodoListClient and TodoListService
23-
// are represented using the same Application Id - we use
24-
// the Application Id to represent the audience, or the
25-
// intended recipient of tokens.
26-
27-
ValidAudience = clientId,
22+
ValidAudience = audience,
2823

2924
// In a real applicaiton, you might use issuer validation to
3025
// verify that the user's organization (if applicable) has
3126
// signed up for the app. Here, we'll just turn it off.
32-
3327
ValidateIssuer = false,
3428
};
3529

0 commit comments

Comments
 (0)