Forum Discussion
Keith_Fleming
Jun 29, 2022Microsoft
Hi,
For MDCA there are a few different ways you can connect to the REST endpoints.
You can create an application in AAD and then use client secret/client ID to exchange for an access token which then needs to be added to the HTTP request header. This is the newer method and here are a couple of articles that talk more about it.
https://docs.microsoft.com/en-us/defender-cloud-apps/api-authentication-application
https://github.com/AzureAD/microsoft-authentication-library-for-python
There is a second legacy method using an API key which is generated in the MDCA portal. In this case the token stays static.
https://docs.microsoft.com/en-us/defender-cloud-apps/api-tokens-legacy
For MDCA there are a few different ways you can connect to the REST endpoints.
You can create an application in AAD and then use client secret/client ID to exchange for an access token which then needs to be added to the HTTP request header. This is the newer method and here are a couple of articles that talk more about it.
https://docs.microsoft.com/en-us/defender-cloud-apps/api-authentication-application
https://github.com/AzureAD/microsoft-authentication-library-for-python
There is a second legacy method using an API key which is generated in the MDCA portal. In this case the token stays static.
https://docs.microsoft.com/en-us/defender-cloud-apps/api-tokens-legacy
- mdenningJun 29, 2022Copper Contributor
Thanks for the response! I have looked into both methods some. The second legacy method seems more appealing to me as the first seems like it wants the user to set a time limit for the credentials, which I don't really want to do (as well as the second method looks simpler). I have generated the static token by following the directions in the link to the documentation, but don't really know what to do next. Do I still need to use the Microsoft authentication library for python to access the data if I use this method? I tried using the token in the requests library to access the data, but I haven't gotten it to work. Thanks for you help so far!
- mdenningJun 30, 2022Copper ContributorNeverminded, I think I got it work work. I just needed to make a get request with the request python library to the url I wanted and supply the token in the header as {"Authorization": "Token <token_here>"}. Thanks!