@@ -167,25 +167,25 @@ See [Microsoft Authentication Library (MSAL) for Python](https://github.com/Azur
167
167
1. Set TENANT_ID to the Azure tenant ID of the customer that wants to use your app to access Defender for Cloud Apps.
168
168
1. Run the following command:
169
169
170
- ```curl
171
- curl -i -X POST -H "Content-Type:application/x-www-form-urlencoded" -d "grant_type=client_credentials" -d "client_id=%CLIENT_ID%" -d "scope=05a65629-4c1b-48c1-a78b-804c4abdd4af/.default" -d "client_secret=%CLIENT_SECRET%" "https://login.microsoftonline.com/%TENANT_ID%/oauth2/v2.0/token" -k
172
- ```
170
+ ```curl
171
+ curl -i -X POST -H "Content-Type:application/x-www-form-urlencoded" -d "grant_type=client_credentials" -d "client_id=%CLIENT_ID%" -d "scope=05a65629-4c1b-48c1-a78b-804c4abdd4af/.default" -d "client_secret=%CLIENT_SECRET%" "https://login.microsoftonline.com/%TENANT_ID%/oauth2/v2.0/token" -k
172
+ ```
173
173
174
- You get an answer in the following form:
174
+ You get an answer in the following form:
175
175
176
- ``` output
177
- {"token_type":"Bearer","expires_in":3599,"ext_expires_in":0,"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIn <truncated> aWReH7P0s0tjTBX8wGWqJUdDA"}
178
- ```
176
+ ``` output
177
+ {"token_type":"Bearer","expires_in":3599,"ext_expires_in":0,"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIn <truncated> aWReH7P0s0tjTBX8wGWqJUdDA"}
178
+ ```
179
179
180
180
## Validate the token
181
181
182
182
Ensure that you got the correct token:
183
183
184
184
1 . Copy and paste the token you got in the previous step into [ JWT] ( https://jwt.ms ) in order to decode it.
185
- 1 . Validate that you get a 'roles' claim with the desired permissions
185
+ 1 . Validate that you get a 'roles' claim with the desired permissions.
186
186
1 . In the following image, you can see a decoded token acquired from an app with permissions to all Microsoft Defender for Cloud Apps roles:
187
187
188
- :::image type="content" source="media/api-authentication-application/webapp-decoded-token.png" alt-text="Screenshot that shows the decoded token.":::
188
+ :::image type="content" source="media/api-authentication-application/webapp-decoded-token.png" alt-text="Screenshot that shows the decoded token.":::
189
189
190
190
191
191
## Use the token to access Microsoft Defender for Cloud Apps API
@@ -194,19 +194,19 @@ Ensure that you got the correct token:
194
194
1 . Set the authorization header in the http request you send to "Bearer {token}" (Bearer is the authorization scheme).
195
195
1 . The expiration time of the token is one hour. You can send more than one request with the same token.
196
196
197
- The following is an example of sending a request to get a list of alerts ** using C#** :
198
-
199
- ``` C#
200
- var httpClient = new HttpClient ();
201
-
202
- var request = new HttpRequestMessage (HttpMethod .Get , " https://portal.cloudappsecurity.com/cas/api/v1/alerts/" );
203
-
204
- request .Headers .Authorization = new AuthenticationHeaderValue (" Bearer" , token );
205
-
206
- var response = httpClient .SendAsync (request ).GetAwaiter ().GetResult ();
207
-
208
- // Do something useful with the response
209
- ```
197
+ The following is an example of sending a request to get a list of alerts ** using C#** :
198
+
199
+ ``` C#
200
+ var httpClient = new HttpClient ();
201
+
202
+ var request = new HttpRequestMessage (HttpMethod .Get , " https://portal.cloudappsecurity.com/cas/api/v1/alerts/" );
203
+
204
+ request .Headers .Authorization = new AuthenticationHeaderValue (" Bearer" , token );
205
+
206
+ var response = httpClient .SendAsync (request ).GetAwaiter ().GetResult ();
207
+
208
+ // Do something useful with the response
209
+ ```
210
210
211
211
## See also
212
212
0 commit comments