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
> Some information relates to prereleased product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
31
+
> Some information relates to prereleased product which may be substantially modified before its general availability. Microsoft makes no warranties, express or implied, with respect to the information provided here.
32
32
33
33
This page describes how to create an application to get programmatic access to Microsoft Defender XDR without a defined user—for example, if you're creating a daemon or background service.
34
34
35
35
If you need programmatic access to Microsoft Defender XDR on behalf of one or more users, see [Create an app to access Microsoft Defender XDR APIs on behalf of a user](api-create-app-user-context.md) and [Create an app with partner access to Microsoft Defender XDR APIs](api-partner-access.md). If you're not sure which kind of access you need, see [Get started](api-access.md).
36
36
37
37
Microsoft Defender XDR exposes much of its data and actions through a set of programmatic APIs. Those APIs help you automate workflows and make use of Microsoft Defender XDR's capabilities. This API access requires OAuth2.0 authentication. For more information, see [OAuth 2.0 Authorization Code Flow](/azure/active-directory/develop/active-directory-v2-protocols-oauth-code).
38
38
39
-
In general, you'll need to take the following steps to use these APIs:
39
+
In general, you need to take the following steps to use these APIs:
40
40
41
41
- Create a Microsoft Entra application.
42
42
- Get an access token using this application.
@@ -61,7 +61,7 @@ This article explains how to:
61
61
4. On your application page, select **API Permissions** > **Add permission** > **APIs my organization uses** >, type **Microsoft Threat Protection**, and select **Microsoft Threat Protection**. Your app can now access Microsoft Defender XDR.
62
62
63
63
> [!TIP]
64
-
> *Microsoft Threat Protection* is a former name for Microsoft Defender XDR, and will not appear in the original list. You need to start writing its name in the text box to see it appear.
64
+
> *Microsoft Threat Protection* is a former name for Microsoft Defender XDR, and doesn't appear in the original list. You need to start writing its name in the text box to see it appear.
65
65
66
66
:::image type="content" source="/defender/media/apis-in-my-org-tab.PNG" alt-text="The organization's APIs usage tab in the Microsoft Defender portal" lightbox="/defender/media/apis-in-my-org-tab.PNG":::
67
67
@@ -70,7 +70,7 @@ This article explains how to:
70
70
:::image type="content" source="/defender/media/request-api-permissions.PNG" alt-text="The application permission pane in the Microsoft Defender portal" lightbox="/defender/media/request-api-permissions.PNG":::
71
71
72
72
> [!NOTE]
73
-
> You need to select the relevant permissions for your scenario. *Read all incidents* is just an example. To determine which permission you need, please look at the **Permissions** section in the API you want to call.
73
+
> You need to select the relevant permissions for your scenario. *Read all incidents* is just an example. To determine which permission you need, check the **Permissions** section in the API you want to call.
74
74
>
75
75
> For instance, to [run advanced queries](api-advanced-hunting.md), select the 'Run advanced queries' permission; to [isolate a device](/windows/security/threat-protection/microsoft-defender-atp/isolate-machine), select the 'Isolate machine' permission.
76
76
@@ -89,11 +89,11 @@ This article explains how to:
89
89
90
90
:::image type="content" source="/defender/media/app-and-tenant-ids.png" alt-text="The Overview pane in the Microsoft Defender portal" lightbox="/defender/media/app-and-tenant-ids.png":::
91
91
92
-
9.**For Microsoft Defender XDR Partners only**: [Follow these instructions](./api-partner-access.md) for partner access through the Microsoft Defender XDR APIs, set your app to be multi-tenant, so it can be available in all tenants once you receive admin consent. Partner access is **required** for third-party apps—for example, if you create an app that is intended to run in multiple customers' tenants. It is **not required** if you create a service that you want to run in your tenant only, such as an application for your own usage that will only interact with your own data. To set your app to be multi-tenant:
92
+
9.**For Microsoft Defender XDR Partners only**: [Follow these instructions](./api-partner-access.md) for partner access through the Microsoft Defender XDR APIs, set your app to be multitenant, so it can be available in all tenants once you receive admin consent. Partner access is **required** for third-party apps—for example, if you create an app that is intended to run in multiple customers' tenants. It is **not required** if you create a service that you want to run in your tenant only, like an application for your own use that only interacts with your own data. To set your app to be multitenant:
93
93
94
94
- Go to **Authentication**, and add https://portal.azure.com as the **Redirect URI**.
95
95
96
-
- On the bottom of the page, under **Supported account types**, select the **Accounts in any organizational directory** application consent for your multi-tenant app.
96
+
- On the bottom of the page, under **Supported account types**, select the **Accounts in any organizational directory** application consent for your multitenant app.
97
97
98
98
Since your application interacts with Microsoft Defender XDR on behalf of your users, it needs be approved for every tenant on which you intend to use it.
99
99
@@ -107,7 +107,7 @@ This article explains how to:
107
107
108
108
The digits `00000000-0000-0000-0000-000000000000` should be replaced with your Application ID.
109
109
110
-
**Done!** You've successfully registered an application! See examples below for token acquisition and validation.
110
+
**Done!** You've successfully registered an application! See the following examples for token acquisition and validation.
111
111
112
112
## Get an access token
113
113
@@ -149,7 +149,7 @@ return $token
149
149
> The following code was tested with Nuget Microsoft.Identity.Client 3.19.8.
150
150
151
151
> [!IMPORTANT]
152
-
> The [Microsoft.IdentityModel.Clients.ActiveDirectory](https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory) NuGet package and Azure AD Authentication Library (ADAL) have been deprecated. No new features have been added since June 30, 2020. We strongly encourage you to upgrade, see the [migration guide](/azure/active-directory/develop/msal-migration) for more details.
152
+
> The [Microsoft.IdentityModel.Clients.ActiveDirectory](https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory) NuGet package and Azure AD Authentication Library (ADAL) were deprecated. No new features were added since June 30, 2020. We strongly encourage you to upgrade, see the [migration guide](/azure/active-directory/develop/msal-migration) for more details.
2. IntheHTTP-basedrequestyou're about to send, set the authorization header to `"Bearer" <token>`, *Bearer* being the authorization scheme, and *token* being your validated token.
> Some information relates to prereleased product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
31
+
> Some information relates to prereleased product which may be substantially modified before its general availability. Microsoft makes no warranties, express or implied, with respect to the information provided here.
32
32
33
33
## Get incidents using a simple PowerShell script
34
34
@@ -44,12 +44,12 @@ It should take 5 to 10 minutes to complete this project. This time estimate incl
44
44
45
45
:::image type="content" source="/defender/media/atp-azure-new-app2.png" alt-text="The New registration section in the Microsoft Defender portal" lightbox="/defender/media/atp-azure-new-app2.png":::
46
46
47
-
3. In the registration form, choose a name for your application, then select **Register**. Selecting a redirect URI is optional. You won't need one to complete this example.
47
+
3. In the registration form, choose a name for your application, then select **Register**. Selecting a redirect URI is optional. You don't need one to complete this example.
48
48
49
49
4. On your application page, select **API Permissions** > **Add permission** > **APIs my organization uses** >, type **Microsoft Threat Protection**, and select **Microsoft Threat Protection**. Your app can now access Microsoft Defender XDR.
50
50
51
51
> [!TIP]
52
-
> *Microsoft Threat Protection* is a former name for Microsoft Defender XDR, and will not appear in the original list. You need to start writing its name in the text box to see it appear.
52
+
> *Microsoft Threat Protection* is a former name for Microsoft Defender XDR, and doesn't appear in the original list. You need to start writing its name in the text box to see it appear.
53
53
:::image type="content" source="/defender/media/apis-in-my-org-tab.PNG" alt-text="The section of APIs usage in the Microsoft Defender portal" lightbox="/defender/media/apis-in-my-org-tab.PNG":::
54
54
55
55
- Choose **Application permissions** > **Incident.Read.All** and select **Add permissions**.
@@ -77,11 +77,11 @@ It should take 5 to 10 minutes to complete this project. This time estimate incl
77
77
For more information on Microsoft Entra tokens, see the [Microsoft Entra tutorial](/azure/active-directory/develop/active-directory-v2-protocols-oauth-client-creds).
78
78
79
79
> [!IMPORTANT]
80
-
> Although the example in this demo app encourage you to paste in your secret value for testing purposes, you should **never hardcode secrets** into an application running in production. A third party could use your secret to access resources. You can help keep your app's secrets secure by using [Azure Key Vault](/azure/key-vault/general/about-keys-secrets-certificates). For a practical example of how you can protect your app, see [Manage secrets in your server apps with Azure Key Vault](/training/modules/manage-secrets-with-azure-key-vault/).
80
+
> Although the example in this demo app encourages you to paste in your secret value for testing purposes, you should **never hardcode secrets** into an application running in production. A third party could use your secret to access resources. You can help keep your app's secrets secure by using [Azure Key Vault](/azure/key-vault/general/about-keys-secrets-certificates). For a practical example of how you can protect your app, see [Manage secrets in your server apps with Azure Key Vault](/training/modules/manage-secrets-with-azure-key-vault/).
81
81
82
-
1. Copy the script below and paste it into your favorite text editor. Save as **Get-Token.ps1**. You can also run the code as-is in PowerShell ISE, but you should save it, because we'll need to run it again when we use the incident-fetching script in the next section.
82
+
1. Copy the following script and paste it into your favorite text editor. Save as **Get-Token.ps1**. You can also run the code as-is in PowerShell ISE, but you need save it because we need to run it again when we use the incident-fetching script in the next section.
83
83
84
-
This script will generate a token and save it in the working folder under the name, *Latest-token.txt*.
84
+
This script generates a token and save it in the working folder under the name, *Latest-token.txt*.
85
85
86
86
```PowerShell
87
87
# This script gets the app context token and saves it to a file named "Latest-token.txt" under the current directory.
@@ -108,15 +108,15 @@ For more information on Microsoft Entra tokens, see the [Microsoft Entra tutoria
108
108
#### Validate the token
109
109
110
110
1. Copy and paste the token you received into [JWT](https://jwt.ms) to decode it.
111
-
1. *JWT* stands for *JSON Web Token*. The decoded token will contain a number of JSON-formatted items or claims. Make sure that the *roles* claim within the decoded token contains the desired permissions.
111
+
1. *JWT* stands for *JSON Web Token*. The decoded token contains several of JSON-formatted items or claims. Make sure that the *roles* claim within the decoded token contains the desired permissions.
112
112
113
113
In the following image, you can see a decoded token acquired from an app, with ```Incidents.Read.All```, ```Incidents.ReadWrite.All```, and ```AdvancedHunting.Read.All``` permissions:
114
114
115
115
:::image type="content" source="/defender/media/api-jwt-ms.png" alt-text="The Decoded Token section in the Microsoft Defender portal" lightbox="/defender/media/api-jwt-ms.png":::
116
116
117
117
### Get a list of recent incidents
118
118
119
-
The script below will use **Get-Token.ps1** to access the API. It then retrieves a list of incidents that were last updated within the past 48 hours, and saves the list as a JSON file.
119
+
The following script uses **Get-Token.ps1** to access the API. It then retrieves a list of incidents that were last updated within the past 48 hours, and saves the list as a JSON file.
120
120
121
121
> [!IMPORTANT]
122
122
> Save this script in the same folder you saved **Get-Token.ps1**.
@@ -171,7 +171,7 @@ You're all done! You've successfully:
171
171
-[Access the Microsoft Defender XDR APIs](api-access.md)
172
172
-[Create an app to access Microsoft Defender XDR without a user](api-create-app-web.md)
173
173
-[Create an app to access Microsoft Defender XDR APIs on behalf of a user](api-create-app-user-context.md)
174
-
-[Create an app with multi-tenant partner access to Microsoft Defender XDR APIs](api-partner-access.md)
174
+
-[Create an app with multitenant partner access to Microsoft Defender XDR APIs](api-partner-access.md)
175
175
-[Manage secrets in your server apps with Azure Key Vault](/training/modules/manage-secrets-with-azure-key-vault/)
176
176
-[OAuth 2.0 Authorization for user sign in and API access](/azure/active-directory/develop/active-directory-v2-protocols-oauth-code)
0 commit comments