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: articles/active-directory/develop/web-api-tutorial-01-register-app.md
+37-37Lines changed: 37 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,63 +10,63 @@ ms.date: 11/1/2022
10
10
#Customer intent: As an application developer, I want to know how to register my application with the Microsoft identity platform so that the security token service can issue access tokens to client applications that request them.
11
11
---
12
12
13
-
# Tutorial: Register a web API with the Microsoft identity platform
13
+
# Tutorial: Register a web API with the Microsoft identity platform
14
14
15
-
To interact with the Microsoft identity platform, Azure Active Directory (Azure AD) must be made aware of the application you create. This tutorial shows you how to register an application in a tenant on the Azure portal.
15
+
To interact with the Microsoft identity platform, Azure Active Directory (Azure AD) must be made aware of the application you create. This tutorial shows you how to register an application in a tenant on the Azure portal.
16
16
17
-
In this tutorial:
17
+
In this tutorial:
18
18
19
-
> [!div class="checklist"]
20
-
> * Register a web API in a tenant
21
-
> * Record the web API's unique identifiers
22
-
> * Expose an API by adding a scope
19
+
> [!div class="checklist"]
20
+
> * Register a web API in a tenant
21
+
> * Record the web API's unique identifiers
22
+
> * Expose an API by adding a scope
23
23
24
-
## Prerequisites
24
+
## Prerequisites
25
25
26
-
* An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/).
27
-
* This Azure account must have permissions to manage applications. Use any of the following roles needed to register the application:
28
-
* Application administrator
29
-
* Application developer
26
+
* An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/).
27
+
* This Azure account must have permissions to manage applications. Use any of the following roles needed to register the application:
28
+
* Application administrator
29
+
* Application developer
30
30
* Cloud application administrator
31
31
32
-
## Register the application and record identifiers
32
+
## Register the application and record identifiers
33
33
34
-
To complete registration, provide the application a name and specify the supported account types. Once registered, the application **Overview** page will display the identifiers needed in the application source code.
34
+
To complete registration, provide the application a name and specify the supported account types. Once registered, the application **Overview** page will display the identifiers needed in the application source code.
35
35
36
-
1. Sign in to the [Azure portal](https://portal.azure.com/).
37
-
1. If access to multiple tenants is available, use the **Directories + subscriptions** filter :::image type="icon" source="media/common/portal-directory-subscription-filter.png" border="false"::: in the top menu to switch to the tenant in which you want to register the application.
38
-
1. Search for and select **Azure Active Directory**.
39
-
1. Under **Manage**, select **App registrations > New registration**.
40
-
1. Enter a **Name** for the application, such as *NewWebAPI1*.
41
-
1. For **Supported account types**, select **Accounts in this organizational directory only**. For information on different account types, select **Help me choose** option.
42
-
1. Select **Register**.
36
+
1. Sign in to the [Azure portal](https://portal.azure.com/).
37
+
1. If access to multiple tenants is available, use the **Directories + subscriptions** filter :::image type="icon" source="media/common/portal-directory-subscription-filter.png" border="false"::: in the top menu to switch to the tenant in which you want to register the application.
38
+
1. Search for and select **Azure Active Directory**.
39
+
1. Under **Manage**, select **App registrations > New registration**.
40
+
1. Enter a **Name** for the application, such as *NewWebAPI1*.
41
+
1. For **Supported account types**, select **Accounts in this organizational directory only**. For information on different account types, select **Help me choose** option.
42
+
1. Select **Register**.
43
43
44
-
:::image type="content" source="./media/web-api-tutorial-01-register-app/register-application.png" alt-text="Screenshot that shows how to enter a name and select the account type.":::
44
+
:::image type="content" source="./media/web-api-tutorial-01-register-app/register-application.png" alt-text="Screenshot that shows how to enter a name and select the account type.":::
45
45
46
-
1. The application's **Overview** pane is displayed when registration is complete. Record the **Directory (tenant) ID** and the **Application (client) ID** to be used in your application source code.
46
+
1. The application's **Overview** pane is displayed when registration is complete. Record the **Directory (tenant) ID** and the **Application (client) ID** to be used in your application source code.
47
47
48
-
:::image type="content" source="./media/web-api-tutorial-01-register-app/record-identifiers.png" alt-text="Screenshot that shows the identifier values on the overview page.":::
48
+
:::image type="content" source="./media/web-api-tutorial-01-register-app/record-identifiers.png" alt-text="Screenshot that shows the identifier values on the overview page.":::
49
49
50
50
>[!NOTE]
51
51
> The **Supported account types** can be changed by referring to [Modify the accounts supported by an application](howto-modify-supported-accounts.md).
52
52
53
-
## Expose an API
53
+
## Expose an API
54
54
55
55
Once the API is registered, you can configure its permission by defining the scopes that the API exposes to client applications. Client applications request permission to perform operations by passing an access token along with its requests to the protected web API. The web API then performs the requested operation only if the access token it receives contains the required scopes.
56
56
57
-
1. Under **Manage**, select **Expose an API > Add a scope**. Accept the proposed **Application ID URI**`(api://{clientId})` by selecting **Save and continue**. The `{clientId}` will be the value recorded from the **Overview** page. Then enter the following information:
58
-
1. For **Scope name**, enter `Forecast.Read`.
59
-
1. For **Who can consent**, ensure that the **Admins and users** option is selected.
60
-
1. In the **Admin consent display name** box, enter `Read forecast data`.
61
-
1. In the **Admin consent description** box, enter `Allows the application to read weather forecast data`.
62
-
1. In the **User consent display name** box, enter `Read forecast data`.
63
-
1. In the **User consent description** box, enter `Allows the application to read weather forecast data`.
57
+
1. Under **Manage**, select **Expose an API > Add a scope**. Accept the proposed **Application ID URI**`(api://{clientId})` by selecting **Save and continue**. The `{clientId}` will be the value recorded from the **Overview** page. Then enter the following information:
58
+
1. For **Scope name**, enter `Forecast.Read`.
59
+
1. For **Who can consent**, ensure that the **Admins and users** option is selected.
60
+
1. In the **Admin consent display name** box, enter `Read forecast data`.
61
+
1. In the **Admin consent description** box, enter `Allows the application to read weather forecast data`.
62
+
1. In the **User consent display name** box, enter `Read forecast data`.
63
+
1. In the **User consent description** box, enter `Allows the application to read weather forecast data`.
64
64
1. Ensure that the **State** is set to **Enabled**.
65
-
1. Select **Add scope**. If the scope has been entered correctly, it'll be listed in the **Expose an API** pane.
65
+
1. Select **Add scope**. If the scope has been entered correctly, it'll be listed in the **Expose an API** pane.
66
66
67
-
:::image type="content" source="./media/web-api-tutorial-01-register-app/add-a-scope-inline.png" alt-text="Screenshot that shows the field values when adding the scope to an API." lightbox="./media/web-api-tutorial-01-register-app/add-a-scope-expanded.png":::
67
+
:::image type="content" source="./media/web-api-tutorial-01-register-app/add-a-scope-inline.png" alt-text="Screenshot that shows the field values when adding the scope to an API." lightbox="./media/web-api-tutorial-01-register-app/add-a-scope-expanded.png":::
68
68
69
-
## Next steps
69
+
## Next steps
70
70
71
-
> [!div class="nextstepaction"]
72
-
> [Tutorial: Create an ASP.NET Core project and configure the API](web-api-tutorial-02-prepare-api.md)
71
+
> [!div class="nextstepaction"]
72
+
> [Tutorial: Create an ASP.NET Core project and configure the API](web-api-tutorial-02-prepare-api.md)
Copy file name to clipboardExpand all lines: articles/active-directory/develop/web-api-tutorial-02-prepare-api.md
+28-29Lines changed: 28 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,27 +14,27 @@ ms.date: 11/1/2022
14
14
15
15
After registration is complete, a ASP.NET Core project can be created using an integrated development environment (IDE). This tutorial demonstrates how to create an ASP.NET Core project using an IDE and configure for authentication and authorization.
16
16
17
-
In this tutorial:
17
+
In this tutorial:
18
18
19
-
> [!div class="checklist"]
19
+
> [!div class="checklist"]
20
20
> * Create an **ASP.NET Core Empty**
21
-
> * Configure the settings for the application
22
-
> * Identify and install the required NuGet packages
21
+
> * Configure the settings for the application
22
+
> * Identify and install the required NuGet packages
23
23
24
-
## Prerequisites
24
+
## Prerequisites
25
25
26
26
* Completion of the prerequisites and steps in [Tutorial: Register web API with the Microsoft identity platform](web-api-tutorial-01-register-app.md).
27
-
* You can download the IDEs used in this tutorial from the [Downloads](https://visualstudio.microsoft.com/downloads) page.
28
-
- Visual Studio 2022
29
-
- Visual Studio Code
30
-
- Visual Studio 2022 for Mac
31
-
- A minimum requirement of [.NET Core 6.0 SDK](https://dotnet.microsoft.com/download/dotnet).
27
+
* You can download the IDEs used in this tutorial from the [Downloads](https://visualstudio.microsoft.com/downloads) page.
28
+
- Visual Studio 2022
29
+
- Visual Studio Code
30
+
- Visual Studio 2022 for Mac
31
+
- A minimum requirement of [.NET Core 6.0 SDK](https://dotnet.microsoft.com/download/dotnet).
32
32
33
-
## Create an ASP.NET Core project
33
+
## Create an ASP.NET Core project
34
34
35
-
Use the following tabs to create an ASP.NET Core project within an IDE.
35
+
Use the following tabs to create an ASP.NET Core project within an IDE.
36
36
37
-
### [Visual Studio](#tab/visual-studio)
37
+
### [Visual Studio](#tab/visual-studio)
38
38
39
39
1. Open Visual Studio, and then select **Create a new project**.
40
40
1. Search for and choose the **ASP.NET Core Empty** template, and then select **Next**.
@@ -43,13 +43,13 @@ Use the following tabs to create an ASP.NET Core project within an IDE.
43
43
1. Accept the default for the **Framework** and **Configure for HTTPS**.
44
44
1. Select **Create**.
45
45
46
-
### [Visual Studio Code](#tab/visual-studio-code)
46
+
### [Visual Studio Code](#tab/visual-studio-code)
47
47
48
-
1. Open Visual Studio Code, select **File > Open Folder...**. Navigate to and select the location in which to create your project.
48
+
1. Open Visual Studio Code, select **File > Open Folder...**. Navigate to and select the location in which to create your project.
49
49
1. Open up a new terminal by selecting **Terminal** in the top bar, then **New Terminal**.
50
50
1. Create a new folder using the **New Folder...** icon in the **Explorer** pane. Provide a name similar to the one registered previously, for example, *NewWebAPILocal*.
51
51
1. Open a new terminal by selecting **Terminal > New Terminal**.
52
-
1. To create an **ASP.NET Core Empty** template, run the following commands in the terminal to change into the directory and create the project:
52
+
1. To create an **ASP.NET Core Empty** template, run the following commands in the terminal to change into the directory and create the project:
53
53
54
54
```powershell
55
55
cd NewWebAPILocal
@@ -70,7 +70,7 @@ Use the following tabs to create an ASP.NET Core project within an IDE.
70
70
71
71
The values recorded earlier will be used in *appsettings.json* to configure the application for authentication. *appsettings.json* is a configuration file that is used to store application settings used during run-time.
72
72
73
-
1. Open *appsettings.json* and replace the file contents with the following code snippet:
73
+
1. Open *appsettings.json* and replace the file contents with the following code snippet:
74
74
75
75
```json
76
76
{
@@ -102,25 +102,24 @@ Identity related **NuGet packages** must be installed in the project for authent
102
102
103
103
### [Visual Studio](#tab/visual-studio)
104
104
105
-
1. In the top menu, select **Tools** > **NuGet Package Manager** > **Manage NuGet Packages for Solution**.
106
-
1. With the **Browse** tab selected, search for **Microsoft.Identity.Web**, select the `Microsoft.Identity.Web` package, select the **Project** checkbox, and then select **Install**.
107
-
1. Select **Ok** or **I Accept** for other windows that may appear.
105
+
1. In the top menu, select **Tools** > **NuGet Package Manager** > **Manage NuGet Packages for Solution**.
106
+
1. With the **Browse** tab selected, search for **Microsoft.Identity.Web**, select the `Microsoft.Identity.Web` package, select the **Project** checkbox, and then select **Install**.
107
+
1. Select **Ok** or **I Accept** for other windows that may appear.
108
108
109
-
### [Visual Studio Code](#tab/visual-studio-code)
109
+
### [Visual Studio Code](#tab/visual-studio-code)
110
110
111
-
1. In the terminal opened in the previous section, enter the following command:
111
+
1. In the terminal opened in the previous section, enter the following command:
112
112
113
113
```powershell
114
-
dotnet add package Microsoft.Identity.Web
114
+
dotnet add package Microsoft.Identity.Web
115
115
```
116
116
117
-
### [Visual Studio for Mac](#tab/visual-studio-for-mac)
117
+
### [Visual Studio for Mac](#tab/visual-studio-for-mac)
118
118
119
-
1. In the top menu, select **Tools** > **Manage NuGet Packages**.
120
-
1. Search for **Microsoft.Identity.Web**, select the `Microsoft.Identity.Web` package, select **Project**, and then select **Add Package**.
121
-
1. Modify the search to **Microsoft.Identity.Web.UI** and select **Add Packages**.
122
-
1. In the pop-up, ensure the correct project is selected, then select **Ok**.
123
-
1. Select **Accept** if other **License Acceptance** windows appear.
119
+
1. In the top menu, select **Tools** > **Manage NuGet Packages**.
120
+
1. Search for **Microsoft.Identity.Web**, select the `Microsoft.Identity.Web` package, select **Project**, and then select **Add Package**.
121
+
1. In the pop-up, ensure the correct project is selected, then select **Ok**.
122
+
1. Select **Accept** if other **License Acceptance** windows appear.
Copy file name to clipboardExpand all lines: articles/active-directory/develop/web-api-tutorial-03-protect-endpoint.md
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,27 +8,26 @@ ms.service: active-directory
8
8
ms.topic: tutorial
9
9
ms.date: 11/1/2022
10
10
#Customer intent: As an application developer I want to protect the endpoint of my API and run it to ensure it is listening for HTTP requests
11
-
#TBD
12
11
---
13
12
14
-
# Tutorial: Implement a protected endpoint to your API
13
+
# Tutorial: Implement a protected endpoint to your API
15
14
16
-
Protecting an API endpoint ensures that only authorized users are permitted access. The Microsoft identity platform provides a way to protect API endpoints by using the [Microsoft.Identity.Web](https://www.nuget.org/packages/Microsoft.Identity.Web/) NuGet package.
15
+
Protecting an API endpoint ensures that only authorized users are permitted access. The Microsoft identity platform provides a way to protect API endpoints by using the [Microsoft.Identity.Web](https://www.nuget.org/packages/Microsoft.Identity.Web/) NuGet package.
17
16
18
17
In this tutorial:
19
18
20
-
> [!div class="checklist"]
21
-
> * Implement authentication
22
-
> * Add weather information for the API to display
23
-
> * Test the API with an unauthenticated GET request
19
+
> [!div class="checklist"]
20
+
> * Implement authentication
21
+
> * Add weather information for the API to display
22
+
> * Test the API with an unauthenticated GET request
24
23
25
-
## Prerequisites
24
+
## Prerequisites
26
25
27
26
* Completion of the prerequisites and steps in [Tutorial: Create and configure an ASP.NET Core project for authentication](web-api-tutorial-02-prepare-api.md).
28
27
29
28
## Implement authorization
30
29
31
-
1. Open the *Program.cs* file and replace the contents with the following snippet:
30
+
1. Open the *Program.cs* file and replace the contents with the following snippet:
1. Asimilaroutputtothefollowingshouldbedisplayedintheterminal. Thisconfirmsthattheapplicationisrunningon `http://localhost:{port}` and listening for requests.
118
118
119
119
```powershell
@@ -122,19 +122,19 @@ In this tutorial:
122
122
Nowlisteningon:http://localhost:{port}
123
123
info:Microsoft.Hosting.Lifetime[0]
124
124
Applicationstarted. PressCtrl+Ctoshutdown.
125
-
...
125
+
...
126
126
```
127
127
128
-
### [Visual Studio for Mac](#tab/visual-studio-for-mac)
128
+
### [Visual Studio for Mac](#tab/visual-studio-for-mac)
Thewebpage `http://localhost:{host}` displays an output similar to the following image. This is because the API is being called without authentication. In order to make an authorized call, refer to [Next steps](#next-steps) for how-to guides on how to access a protected web API.
133
+
Thewebpage `http://localhost:{host}` displays an output similar to the following image. This is because the API is being called without authentication. In order to make an authorized call, refer to [Next steps](#next-steps) for how-to guides on how to access a protected web API.
134
134
135
-
:::imagetype="content"source="./media/web-api-tutorial-03-protect-endpoint/display-web-page-401.png"alt-text="Screenshot that shows the 401 error when the web page is launched.":::
135
+
:::imagetype="content"source="./media/web-api-tutorial-03-protect-endpoint/display-web-page-401.png"alt-text="Screenshot that shows the 401 error when the web page is launched.":::
0 commit comments