You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+54-18Lines changed: 54 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ Next time a user runs the application, the user is signed-in with the same ident
48
48
- Install .NET Core for Windows by following the instructions at [dot.net/core](https://dot.net/core), which will include [Visual Studio 2017](https://aka.ms/vsdownload).
49
49
- An Internet connection
50
50
- An Azure Active Directory (Azure AD) tenant. For more information on how to get an Azure AD tenant, see [How to get an Azure AD tenant](https://azure.microsoft.com/en-us/documentation/articles/active-directory-howto-tenant/)
51
-
- A user account in your Azure AD tenant. This sample will not work with a Microsoft account (formerly Windows Live account). Therefore, if you signed in to the [Azure portal](https://portal.azure.com) with a Microsoft account and have never created a user account in your directory before, you need to do that now. (See [Quickstart: Add new users to Azure Active Directory](https://docs.microsoft.com/en-us/azure/active-directory/add-users-azure-active-directory)
51
+
- A user account in your Azure AD tenant, or a Microsoft personal account
There are two projects in this sample. Each needs to be separately registered in your Azure AD tenant. To register these projects, you can:
66
66
67
-
#### Register the TodoListService web API
67
+
#### Navigate to the Application registration portal
68
68
69
-
> TODO Update this
69
+
Sign in in [apps.dev.microsoft.com/](apps.dev.microsoft.com/). From there, you can add converged applications
70
70
71
-
#### Register the TodoListClient app
71
+
#### Register the TodoListClient-v2 app
72
72
73
-
> TODO Update this
73
+
1. In the [application registration portal](apps.dev.microsoft.com), click **Add an app**
74
+
1. In the *Register your application* page, provide a name for your application for instance `TodoListClient-v2`
75
+
1. Press the **Create** button
76
+
1. In the registration page for your application, copy the *application ID* to the clipboard you will need it to configure the code for your application
77
+
1. Press the **Save** button at the bottom of the page.
78
+
1. In the *Platforms* section, click on the **Add Platform** button and then on **Native application**
79
+
1. Click on the My applications link at the top of the page to get back to the list of applications in the app registration portal
80
+
81
+
#### Register the TodoListService-v2 web API
82
+
83
+
1. In the [application registration portal](apps.dev.microsoft.com), click **Add an app**
84
+
1. In the *Register your application* page, provide a name for your application for instance `TodoListService-v2`
85
+
1. Press the **Create** button
86
+
1. In the registration page for your application, copy the *application ID* to the clipboard you will need it to configure the code for your application
87
+
1. In the *Platforms* section, click on the **Add Platform** button and then on **Web API**
88
+
1. Copy the scope proposed by default to access your web api as a user. It's in the form ``api://<Application ID>/access_as_user``
89
+
1. In the *Web API platform*, in the *Pre-authorized applications* section click on **Add application**
90
+
1. In the *application ID* field, paste the application ID of the client application as pasted from the registration
91
+
1. In the *Scope* field, click on the **Select** combo box and select the scope for this Web API `api://<Application ID>/access_as_user`
92
+
1. Press the **Save** button at the bottom of the page.
74
93
75
94
### Step 3: Configure the sample to use your Azure AD tenant
76
95
77
-
#### Configure the TodoListService C# project
96
+
#### Choose which users account to sign in
97
+
98
+
By default the sample is configured to enable users to sign in with any work and school accounts (AAD) or Microsoft Personal accounts (formerly live account).
99
+
This is because `ida:Tenant` has the value of `common`.
100
+
101
+
##### Important note
78
102
79
-
> TODO Update this
103
+
`common` is **not** a proper tenant. It's just a **convention** to express that the accepted tenants are any Work and School organizations, or Personal Microsoft account (consumer accounts).
104
+
Accepted tenants can have the following values:
105
+
106
+
Value | Meaning
107
+
----- | --------
108
+
`common` | users can sign in with any Work and School account, or Microsoft Personal account
109
+
`organizations` | users can sign in with any Work and School account
110
+
`consumers` | users can sign in with a Microsoft Personal account
111
+
a GUID or domain name | users can only sign in with an account for a specific organization described by its tenant ID (GUID) or domain name
112
+
113
+
#### Configure the TodoListService C# project
80
114
81
115
1. Open the solution in Visual Studio.
82
-
2. In the TodoListService project, open the `appsettings.json` file.
83
-
3. Find the `Domain` property and replace the value with your AAD tenant domain, for example, contoso.onmicrosoft.com.
84
-
4. Find the `TenantId` property and replace the value with the Tenant ID you registered earlier,
85
-
5. Find the `ClientId` property and replace the value with the Application ID (Client ID) property of the Service application, that you registered earlier.
116
+
1. In the TodoListService project, open the `appsettings.json` file.
117
+
1. Find the `ClientId` property and replace the value with the Application ID (Client ID) property of the Service application, that you registered earlier.
118
+
1.[Optional] if you want to limit sign-in to users in your organization, also update
119
+
- The `Domain` property, replacing the existing value with your AAD tenant domain, for example, contoso.onmicrosoft.com.
120
+
- The `TenantId` property replacing the existing value with the Tenant ID.
86
121
87
122
#### Configure the TodoListClient C# project
88
123
89
124
1. In the TodoListClient project, open `App.config`.
90
-
2. Find the app key `ida:Tenant` and replace the value with your AAD Tenant ID (GUID). Alternatively you can also use your AAD tenant Name (for example, contoso.onmicrosoft.com).
91
-
3. Find the app key `ida:ClientId` and replace the value with the ApplicationID (Client ID) for the TodoListClient from the Azure portal.
92
-
4. Find the app key `ida:RedirectUri` and replace the value with the Redirect URI for the TodoListClient from the Azure portal, for example `https://TodoListClient`.
93
-
5. Find the app key `todo:TodoListResourceId` and replace the value with the ApplicationID (Client ID) of the Service application (a GUID)
94
-
6. If you changed the default value, find the app key `todo:TodoListBaseAddress` and replace the value with the base address of the TodoListService project.
125
+
1. Find the app key `ida:ClientId` and replace the value with the ApplicationID (Client ID) for the TodoListClient-v2 app copied from the app registration page.
126
+
1. Find the app key `todo:TodoListScope` and replace the value with the scope of the TodoListService-v2 application copied from the app registration (of the form ``api://<Application ID of service>/access_as_user``)
127
+
1.[Optional] If you want your application to work only in your organization (only in your tenant) you'll also need to Find the app key `ida:Tenant` and replace the value with your AAD Tenant ID (GUID). Alternatively you can also use your AAD tenant Name (for example, contoso.onmicrosoft.com)
128
+
1.[Optional] If you changed the default URL for your service application, find the app key `todo:TodoListBaseAddress` and replace the value with the base address of the TodoListService project.
This code gets the todo list items associated with their owner, which is the identity of the user using the Web API. It also adds todo list items associated with the same user.
173
-
There is no persistence as implementing token persistance on the service side would be beyond the scope of this sample
207
+
There is no persistence as implementing token persistence on the service side would be beyond the scope of this sample
174
208
175
209
The code of the `Configure` method in `AzureAdServiceCollectionExtension` was also modified to accept tokens coming from the V2 endpoint:
// Instead of using the default validation (validating against a single tenant, as we do in line of business apps),
184
218
// we inject our own multitenant validation logic (which even accepts both V1 and V2 tokens)
@@ -296,4 +330,6 @@ To understand better how the client code acquires a token, see ADAL.NET's concep
296
330
297
331
### Other documentation / samples
298
332
333
+
This sample is for the Azure AD V2 enpoint the same as [Calling a ASP.NET Core Web API from a WPF application using Azure AD](https://github.com/Azure-Samples/active-directory-dotnet-native-aspnetcore) which is for the Azure AD V1 endpoint.
334
+
299
335
For more information about how the protocols work in this scenario and other scenarios, see [Authentication Scenarios for Azure AD](https://go.microsoft.com/fwlink/?LinkId=394414).
0 commit comments