Skip to content

Commit 1c9858e

Browse files
authored
Merge pull request #89024 from MicrosoftDocs/master
9/18 PM Publish
2 parents cd70273 + 9cefb5d commit 1c9858e

File tree

169 files changed

+2714
-1601
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+2714
-1601
lines changed

articles/active-directory-b2c/active-directory-b2c-tutorials-web-api.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: Tutorial - Grant access to an ASP.NET web API - Azure Active Directory B2C | Microsoft Docs
2+
title: Tutorial - Grant access to an ASP.NET web API - Azure Active Directory B2C
33
description: Tutorial on how to use Active Directory B2C to protect an ASP.NET web API and call it from an ASP.NET web application.
44
services: active-directory-b2c
55
author: mmacy
66
manager: celestedg
77

88
ms.author: marsma
9-
ms.date: 02/04/2019
9+
ms.date: 09/19/2019
1010
ms.custom: mvc
1111
ms.topic: tutorial
1212
ms.service: active-directory
@@ -78,20 +78,20 @@ There are two projects in the sample solution:
7878

7979
The following two projects are in the sample solution:
8080

81-
- **TaskWebApp** - Create and edit a task list. The sample uses the **sign-up or sign-in** user flow to sign up or sign in users.
82-
- **TaskService** - Supports the create, read, update, and delete task list functionality. The API is protected by Azure AD B2C and called by TaskWebApp.
81+
* **TaskWebApp** - Create and edit a task list. The sample uses the **sign-up or sign-in** user flow to sign up or sign in users.
82+
* **TaskService** - Supports the create, read, update, and delete task list functionality. The API is protected by Azure AD B2C and called by TaskWebApp.
8383

8484
### Configure the web application
8585

8686
1. Open the **B2C-WebAPI-DotNet** solution in Visual Studio.
87-
2. Open **Web.config** in the **TaskWebApp** project.
88-
3. To run the API locally, use the localhost setting for **api:TaskServiceUrl**. Change the Web.config as follows:
87+
1. In the **TaskWebApp** project, open **Web.config**.
88+
1. To run the API locally, use the localhost setting for **api:TaskServiceUrl**. Change the Web.config as follows:
8989

9090
```csharp
9191
<add key="api:TaskServiceUrl" value="https://localhost:44332/"/>
9292
```
9393

94-
3. Configure the URI of the API. This is the URI the web application uses to make the API request. Also, configure the requested permissions.
94+
1. Configure the URI of the API. This is the URI the web application uses to make the API request. Also, configure the requested permissions.
9595

9696
```csharp
9797
<add key="api:ApiIdentifier" value="https://<Your tenant name>.onmicrosoft.com/api/" />
@@ -101,26 +101,27 @@ The following two projects are in the sample solution:
101101

102102
### Configure the web API
103103

104-
1. Open **Web.config** in the **TaskService** project.
105-
2. Configure the API to use your tenant.
104+
1. In the **TaskService** project, open **Web.config**.
105+
1. Configure the API to use your tenant.
106106

107107
```csharp
108+
<add key="ida:AadInstance" value="https://<Your tenant name>.b2clogin.com/{0}/{1}/v2.0/.well-known/openid-configuration" />
108109
<add key="ida:Tenant" value="<Your tenant name>.onmicrosoft.com" />
109110
```
110111

111-
3. Set the client ID to the registered Application ID for your API.
112+
1. Set the client ID to the Application ID of your registered web API application, *webapi1*.
112113

113114
```csharp
114115
<add key="ida:ClientId" value="<application-ID>"/>
115116
```
116117

117-
4. Update the user flow setting with the name of the sign up and sign-in user flow.
118+
1. Update the user flow setting with the name of your sign-up and sign-in user flow, *B2C_1_signupsignin1*.
118119

119120
```csharp
120-
<add key="ida:SignUpSignInUserFlowId" value="B2C_1_signupsignin1" />
121+
<add key="ida:SignUpSignInPolicyId" value="B2C_1_signupsignin1" />
121122
```
122123

123-
5. Configure the scopes setting to match what you created in the portal.
124+
1. Configure the scopes setting to match those you created in the portal.
124125

125126
```csharp
126127
<add key="api:ReadScope" value="Hello.Read" />
@@ -132,17 +133,17 @@ The following two projects are in the sample solution:
132133
You need to run both the **TaskWebApp** and **TaskService** projects.
133134

134135
1. In Solution Explorer, right-click on the solution and select **Set StartUp Projects...**.
135-
2. Select **Multiple startup projects**.
136-
3. Change the **Action** for both projects to **Start**.
137-
4. Click **OK** to save the configuration.
138-
5. Press **F5** to run both applications. Each application opens in its own browser tab.
139-
`https://localhost:44316/` is the web application.
140-
`https://localhost:44332/` is the web API.
136+
1. Select **Multiple startup projects**.
137+
1. Change the **Action** for both projects to **Start**.
138+
1. Click **OK** to save the configuration.
139+
1. Press **F5** to run both applications. Each application opens in its own browser window.
140+
* `https://localhost:44316/` is the web application.
141+
* `https://localhost:44332/` is the web API.
141142

142-
6. In the web application, click **sign-up / sign-in** to sign in to the web application. Use the account that you previously created.
143-
7. After you sign in, click **To-do list** and create a to-do list item.
143+
1. In the web application, select **sign-up / sign-in** to sign in to the web application. Use the account that you previously created.
144+
1. After you sign in, select **To-do list** and create a to-do list item.
144145

145-
When you create a to-do list item, the web application makes a request to the web API to generate the to-do list item. You're protected web application is calling the protected web API in your Azure AD B2C tenant.
146+
When you create a to-do list item, the web application makes a request to the web API to generate the to-do list item. Your protected web application is calling the web API protected by Azure AD B2C.
146147

147148
## Next steps
148149

articles/active-directory-b2c/active-directory-b2c-tutorials-web-app.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: mmacy
66
manager: celestedg
77

88
ms.author: marsma
9-
ms.date: 09/12/2019
9+
ms.date: 09/19/2019
1010
ms.custom: mvc
1111
ms.topic: tutorial
1212
ms.service: active-directory
@@ -36,13 +36,13 @@ In this tutorial, you learn how to:
3636
In the tutorial that you completed as part of the prerequisites, you added a web application in Azure AD B2C. To enable communication with the sample in this tutorial, you need to add a redirect URI to the application in Azure AD B2C.
3737

3838
1. Sign in to the [Azure portal](https://portal.azure.com).
39-
2. Make sure you're using the directory that contains your Azure AD B2C tenant by selecting the **Directory + subscription** filter in the top menu and choosing the directory that contains your tenant.
40-
3. Choose **All services** in the top-left corner of the Azure portal, and then search for and select **Azure AD B2C**.
41-
4. Select **Applications**, and then select the *webapp1* application.
42-
5. Under **Reply URL**, add `https://localhost:44316`.
43-
6. Select **Save**.
44-
7. On the properties page, record the application ID that you'll use when you configure the web application.
45-
8. Select **Keys**, select **Generate key**, and select **Save**. Record the key that you'll use when you configure the web application.
39+
1. Make sure you're using the directory that contains your Azure AD B2C tenant by selecting the **Directory + subscription** filter in the top menu and choosing the directory that contains your tenant.
40+
1. Choose **All services** in the top-left corner of the Azure portal, and then search for and select **Azure AD B2C**.
41+
1. Select **Applications**, and then select the *webapp1* application.
42+
1. Under **Reply URL**, add `https://localhost:44316`.
43+
1. Select **Save**.
44+
1. On the properties page, record the application ID that you'll use when you configure the web application.
45+
1. Select **Keys**, select **Generate key**, and select **Save**. Record the key that you'll use when you configure the web application.
4646

4747
## Configure the sample
4848

@@ -54,16 +54,16 @@ git clone https://github.com/Azure-Samples/active-directory-b2c-dotnet-webapp-an
5454

5555
The following two projects are in the sample solution:
5656

57-
- **TaskWebApp** - Create and edit a task list. The sample uses the **sign-up or sign-in** user flow to sign up and sign in users.
58-
- **TaskService** - Supports the create, read, update, and delete task list functionality. The API is protected by Azure AD B2C and called by TaskWebApp.
57+
* **TaskWebApp** - Create and edit a task list. The sample uses the **sign-up or sign-in** user flow to sign up and sign in users.
58+
* **TaskService** - Supports the create, read, update, and delete task list functionality. The API is protected by Azure AD B2C and called by TaskWebApp.
5959

6060
You change the sample to use the application that's registered in your tenant, which includes the application ID and the key that you previously recorded. You also configure the user flows that you created. The sample defines the configuration values as settings in the *Web.config* file.
6161

6262
Update the settings in the Web.config file to work with your user flow:
6363

6464
1. Open the **B2C-WebAPI-DotNet** solution in Visual Studio.
6565
1. In the **TaskWebApp** project, open the **Web.config** file.
66-
1. Replace the value of `ida:Tenant` and `ida:AadInstance` with the name of the tenant that you created.
66+
1. Update the value of `ida:Tenant` and `ida:AadInstance` with the name of the Azure AD B2C tenant that you created. For example, replace `fabrikamb2c` with `contoso`.
6767
1. Replace the value of `ida:ClientId` with the application ID that you recorded.
6868
1. Replace the value of `ida:ClientSecret` with the key that you recorded. You must XML-encode the client secret before adding it to your Web.config.
6969
1. Replace the value of `ida:SignUpSignInPolicyId` with `b2c_1_signupsignin1`.
@@ -73,19 +73,21 @@ Update the settings in the Web.config file to work with your user flow:
7373
## Run the sample
7474

7575
1. In Solution Explorer, right-click the **TaskWebApp** project, and then click **Set as StartUp Project**.
76-
2. Press **F5**. The default browser launches to the local web site address `https://localhost:44316/`.
76+
1. Press **F5**. The default browser launches to the local web site address `https://localhost:44316/`.
7777

7878
### Sign up using an email address
7979

80-
1. Click **Sign up / Sign in** to sign up as a user of the application. The **b2c_1_signupsignin1** user flow is used.
81-
2. Azure AD B2C presents a sign-in page with a sign-up link. Since you don't have an account yet, select **Sign up now**. The sign-up workflow presents a page to collect and verify the user's identity using an email address. The sign-up workflow also collects the user's password and the requested attributes defined in the user flow.
82-
3. Use a valid email address and validate using the verification code. Set a password. Enter values for the requested attributes.
80+
1. Select **Sign up / Sign in** to sign up as a user of the application. The **b2c_1_signupsignin1** user flow is used.
81+
1. Azure AD B2C presents a sign-in page with a sign-up link. Since you don't have an account yet, select **Sign up now**. The sign-up workflow presents a page to collect and verify the user's identity using an email address. The sign-up workflow also collects the user's password and the requested attributes defined in the user flow.
82+
1. Use a valid email address and validate using the verification code. Set a password. Enter values for the requested attributes.
8383

8484
![Sign-up page shown as part of sign-in/sign-up workflow](media/active-directory-b2c-tutorials-web-app/sign-up-workflow.PNG)
8585

86-
4. Click **Create** to create a local account in the Azure AD B2C tenant.
86+
1. Select **Create** to create a local account in the Azure AD B2C tenant.
8787

88-
Now the user can use their email address to sign in and use the web application.
88+
The application user can now use their email address to sign in and use the web application.
89+
90+
However, the **To-Do List** feature won't function until you complete the next tutorial in the series, [Tutorial: Use Azure AD B2C to protect an ASP.NET web API](active-directory-b2c-tutorials-web-api.md).
8991

9092
## Next steps
9193

@@ -96,5 +98,7 @@ In this tutorial, you learned how to:
9698
> * Configure the sample to use the application
9799
> * Sign up using the user flow
98100
101+
Now move on to the next tutorial to enable the **To-Do List** feature of the web application. In it, you register a web API application in your own Azure AD B2C tenant, and then modify the code sample to use your tenant for API authentication.
102+
99103
> [!div class="nextstepaction"]
100-
> [Tutorial: Use Azure Active Directory B2C to protect an ASP.NET web API](active-directory-b2c-tutorials-web-api.md)
104+
> [Tutorial: Use Azure Active Directory B2C to protect an ASP.NET web API >](active-directory-b2c-tutorials-web-api.md)

0 commit comments

Comments
 (0)