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
+60-22Lines changed: 60 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,56 +32,94 @@ You can clone this sample from your shell or command line:
32
32
33
33
### Step 2: Register your Web API - *TodoListService* in the *Application registration portal*
34
34
35
-
1. Sign in to the [Application registration portal](https://apps.dev.microsoft.com/portal/register-app) either using a personal Microsoft account (live.com or hotmail.com) or work or school account.
36
-
1. Give a name to your Application, such as `AppModelv2-NativeClient-DotNet-TodoListService`. Make sure that the *Guided Setup* option is **Unchecked** then press **Create**. The portal will assign your app a globally unique *Application ID* that you'll use later in your code.
37
-
1. Click **Add Platform**, and select **Web API**
38
-
1. Click **Save**
39
-
40
-
> Note: When you add a *Web API* the Application registration portal, it adds a pre-defined App Id URI and Scope, using the format *api://{Application Id}/{Scope Name}* named **access_as_user** (you can review it by clicking 'Edit' button). This sample code uses this default scope.
41
-
42
-
### Step 3: Configure your *TodoListService* and *TodoListClient* projects to match the Web API you just registered
35
+
#### Choose the Azure AD tenant where you want to create your applications
36
+
37
+
If you want to register your apps manually, as a first step you'll need to:
38
+
39
+
1. Sign in to the [Azure portal](https://portal.azure.com) using either a work or school account or a personal Microsoft account.
40
+
1. If your account is present in more than one Azure AD tenant, select your profile at the top right corner in the menu on top of the page, and then **switch directory**.
41
+
Change your portal session to the desired Azure AD tenant.
42
+
43
+
#### Register the service app (TodoListService)
44
+
45
+
1. Navigate to the Microsoft identity platform for developers [App registrations](https://go.microsoft.com/fwlink/?linkid=2083908) page.
46
+
1. Select **New registration**.
47
+
1. When the **Register an application page** appears, enter your application's registration information:
48
+
- In the **Name** section, enter a meaningful application name that will be displayed to users of the app, for example `AppModelv2-NativeClient-DotNet-TodoListService`.
49
+
- Change **Supported account types** to **Accounts in any organizational directory**.
50
+
- Select **Register** to create the application.
51
+
52
+
1. On the app **Overview** page, find the **Application (client) ID** value and record it for later. You'll need it to configure the Visual Studio configuration file for this project (`ClientId` in `TodoListService\Web.config`).
53
+
1. Select the **Expose an API** section, and:
54
+
- Select **Add a scope**
55
+
- accept the proposed Application ID URI (api://{clientId}) by selecting **Save and Continue**
56
+
- Enter the following parameters:
57
+
- for **Scope name** use `access_as_user`
58
+
- Ensure the **Admins and users** option is selected for **Who can consent**
59
+
- in **Admin consent display name** type `Access TodoListService as a user`
60
+
- in **Admin consent description** type `Accesses the TodoListService Web API as a user`
61
+
- in **User consent display name** type `Access TodoListService as a user`
62
+
- in **User consent description** type `Accesses the TodoListService Web API as a user`
63
+
- Keep **State** as **Enabled**
64
+
- Select **Add scope**
65
+
66
+
#### Configure your *TodoListService* and *TodoListClient* projects to match the Web API you just registered
43
67
44
68
1. Open the solution in Visual Studio and then open the **Web.config** file under the root of **TodoListService** project.
45
-
1. Replace the value of `ida:ClientId` parameter with the **Application Id** from the application you just registered in the Application Registration Portal.
69
+
1. Replace the value of `ida:ClientId` parameter with the **Client ID (Application Id)** from the application you just registered in the Application Registration Portal.
46
70
47
-
#### Step 3.1: Add the new scope to the *TodoListClient*`s app.config
71
+
#### Add the new scope to the *TodoListClient*`s app.config
48
72
49
-
1. Open the **app.config** file located in **TodoListClient** project's root folder and then paste **Application Id** from the application you just registered for your *TodoListService* under `TodoListServiceScope` parameter, replacing the string `{Enter the Application Id of your TodoListService from the app registration portal}`.
73
+
1. Open the **app.config** file located in **TodoListClient** project's root folder and then paste **Application Id** from the application you just registered for your *TodoListService* under `TodoListServiceScope` parameter, replacing the string `{Enter the Application Id of your TodoListService from the app registration portal}`.
50
74
51
75
> Note: Make sure it uses has the format `api://{TodoListService-Application-Id}/access_as_user` (where {TodoListService-Application-Id} is the Guid representing the Application Id for your TodoListService).
52
76
53
-
### Step 4: Register the *TodoListClient* application in the *Application registration portal*
77
+
### Step 3: Register the client app (TodoListClient)
78
+
79
+
In this step, you configure your *TodoListClient* project by registering a new application in the Application registration portal. In the cases where the client and server are considered *the same application* you may also just reuse the same application registered in the 'Step 2.'. Using the same application is actually needed if you want users to sign-in with Microsoft personal accounts
54
80
55
-
In this step, you configure your *TodoListClient*project by registering a new application in the Application registration portal. In the cases where the client and server are considered *the same application* you may also just reuse the same application registered in the 'Step 2.'.
81
+
#### Register the *TodoListClient* application in the *Application registration portal*
56
82
57
-
1. Go back to [Application registration portal](https://apps.dev.microsoft.com/portal/register-app) to register a new application
58
-
1. Give a name to your Application, such as `NativeClient-DotNet-TodoListClient`, make sure that the *Guided Setup* option is **Unchecked** then press **Create**.
59
-
1. Click **Add Platform**, and select **Native**.
60
-
1. Click **Save**
83
+
1. Navigate to the Microsoft identity platform for developers [App registrations](https://go.microsoft.com/fwlink/?linkid=2083908) page.
84
+
1. Select **New registration**.
85
+
1. When the **Register an application page** appears, enter your application's registration information:
86
+
- In the **Name** section, enter a meaningful application name that will be displayed to users of the app, for example `NativeClient-DotNet-TodoListClient`.
87
+
- Change **Supported account types** to **Accounts in any organizational directory and personal Microsoft accounts (e.g. Skype, Xbox, Outlook.com)**.
88
+
- Select **Register** to create the application.
89
+
1. On the app **Overview** page, find the **Application (client) ID** value and record it for later. You'll need it to configure the Visual Studio configuration file for this project (`ida:ClientId` in `TodoListClient\App.Config`).
90
+
1. From the app's Overview page, select the **Authentication** section.
91
+
- In the **Redirect URLs** | **Suggested Redirect URLs for public clients (mobile, desktop)** section, check **urn:ietf:wg:oauth:2.0:oob**
92
+
- Select **Save**.
93
+
1. Select the **API permissions** section
94
+
- Click the **Add a permission** button and then,
95
+
- Ensure that the **My APIs** tab is selected
96
+
- In the list of APIs, select the `AppModelv2-NativeClient-DotNet-TodoListService API`, or the name you entered for the Web API.
97
+
- In the **Delegated permissions** section, ensure that the right permissions are checked: **access_as_user**. Use the search box if necessary.
98
+
- Select the **Add permissions** button
61
99
62
-
###Step 5: Configure your *TodoListClient* project
100
+
####Configure your *TodoListClient* project
63
101
64
102
1. In the *Application registration portal*, copy the value of the **Application Id**
65
103
1. Open the **app.config** file located in the **TodoListClient** project's root folder and then paste the value in the `ida:ClientId` parameter value
66
104
67
-
### Step 6: Run your project
105
+
### Step 4: Run your project
68
106
69
107
1. Press `<F5>` to run your project. Your *TodoListClient* should open.
70
108
1. Select **Sign in** in the top right and sign in with the same user you have used to register your aplication, or a user in the same directory.
71
109
1. At this point, if you are signing in for the first time, you may be prompted to consent to *TodoListService* Web Api.
72
110
1. The sign-in also request the access token to the *access_as_user* scope to access *TodoListService* Web Api and manipulate the *To-Do* list.
73
111
74
-
### Step 7: Pre-authorize your client application
112
+
### Step 5: Pre-authorize your client application
75
113
76
114
One of the ways to allow users from other directories to acces 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::
77
115
78
116
1. Go back to the *Application registration portal* and open the properties of your **TodoListService**.
79
-
1. In the **Web API platform**, click on **Add application** under the *Pre-authorized applications* section.
117
+
1. In the **Expose an API** section, click on **Add application** under the *Pre-authorized applications* section.
80
118
1. In the *Application ID* field, paste the application ID of the `TodoListClient` application.
81
119
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`.
82
120
1. Press the **Save** button at the bottom of the page.
83
121
84
-
### Step 8: Run your project
122
+
### Step 6: Run your project
85
123
86
124
1. Press `<F5>` to run your project. Your *TodoListClient* should open.
87
125
1. Select **Sign in** in the top right (or Clear Cache/Sign-in) and then sign-in either using a personal Microsoft account (live.com or hotmail.com) or work or school account.
0 commit comments