Move Defender APIs to OAuth2, fix invalid scopes#856
Conversation
Fix old scopes that were causing authentication errors.
There was a problem hiding this comment.
Pull Request Overview
This PR modernizes Microsoft Defender APIs authentication by migrating from OAuth 1.0 to OAuth 2.0 (v2.0 endpoints) and standardizes scope handling across all Defender services. The changes ensure consistent authentication patterns while maintaining backward compatibility for legacy configurations.
- Migrates all Defender APIs (MDE, M365D, M365DGraph) to use OAuth 2.0 v2.0 token endpoints
- Standardizes scope handling to use
{resource}/.defaultpattern instead of specific permissions - Updates documentation to reflect the new OAuth 2.0 authentication flow
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/data/drivers/test_odata_drivers.py | Updates test assertion to expect v2.0 token endpoint |
| msticpy/data/drivers/mdatp_driver.py | Migrates API configurations to OAuth 2.0 endpoints and implements standardized scope handling |
| msticpy/_version.py | Bumps version to 2.17.0 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Using urljoin to join URL parts
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…ng sanitization Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…ng sanitization Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
FlorianBracq
left a comment
There was a problem hiding this comment.
I slightly changed the 'schema' test and applied some minor linting changes.
Also tested the code on my env, and all seems to be working well!
As a side note, some parameters from the init are not documented, I don't know if it's worth addressing in this PR?
Thanks so much for testing it and review. |
This pull request updates the Microsoft Defender and Microsoft 365 Defender data driver to use OAuth 2.0 (v2.0 endpoint and /.default scope) as the default authentication method for all Defender APIs. It also updates relevant documentation, error handling, and test cases to reflect these changes.
Authentication and API configuration updates:
/.defaultscope by default, simplifying and standardizing token acquisition across environments. [1] [2]Testing and versioning:
2.17.0to reflect these significant changes.