To resolve the "Missing application roles" error, ensure that your application has the required permissions correctly set in the Azure portal. Based on your description, it seems you need to verify that the following roles are assigned to your application:
- Alert.Read.All - This permission allows the application to read all alerts.
- Alert.ReadWrite.All - This permission allows the application to read and write alerts.
- Incident.Read.All - This permission allows the application to read all incidents.
- AdvancedHunting.Read.All - This permission allows the application to run advanced hunting queries.
Make sure that these permissions are granted at the application level and that you have consented to them. After setting the permissions, you may need to re-authenticate to obtain a new token that includes these permissions.
If you continue to face issues, double-check the scopes you are using when acquiring the token to ensure they match the required permissions for the API you are trying to access.