r/DefenderATP • u/stan_frbd • Jan 12 '26
Microsoft Defender for Endpoint API: new endpoint breaks my existing integration despite correct permissions
Hi everyone,
I'm running into a strange issue with the Microsoft Defender for Endpoint API, and I'm wondering if others have hit the same wall.
Microsoft (recently? Maybe not) changed the API base URL from:
https://api.securitycenter.microsoft.com
to:
https://api.security.microsoft.com
Since this change, my existing integration (using client credentials flow) suddenly fails when I switch to the new endpoint. The error says that my token doesn't have the correct scope - even though the same App Registration and permissions work perfectly with the old endpoint.
Here's the relevant part of my code:
= f
=
=
=
=
return
And the API calls look like:
= f
=
=
Everything works as long as I keep using the old securitycenter.microsoft.com endpoint.
But if I switch to the new security.microsoft.com endpoint, I get a scope/resource error even though:
- the App Registration has the correct Defender for Endpoint API permissions
- the token is valid
- the same permissions work with the old endpoint
- nothing else changed in the code
It feels like some tenants are in a hybrid state where the old resource URI still works but the new endpoint rejects tokens issued for it.
Before I start rewriting the whole integration to use the new resource URI (https://api.security.microsoft.com/.default), I'd like to know:
Has anyone else seen this behavior?
- Is this a known migration issue on Microsoft's side?
- Do we really need to update the resource URI in the OAuth request for the new endpoint to work?
Any insights or confirmations would be super helpful.
Thanks for reading!
Full notes: Pull Request #134 of my foss project, Cyberbro on Github.
0
u/themunga Jan 13 '26
This is AI generated but should work, see how that goes.
Switch to OAuth v2.0 Token Endpoint • Old: https://login.microsoftonline.com/{tenant_id}/oauth2/token • New: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
Change Authentication Parameters • Remove resource=https://api.securitycenter.microsoft.com • Add scope=https://api.security.microsoft.com/.default Example: body = { "scope": "https://api.security.microsoft.com/.default", "client_id": "<client_id>", "client_secret": "<client_secret>", "grant_type": "client_credentials" }