I am trying to connect from Java to the Sharepoint Online REST API.
I previously used a SharepointOnline ADD-IN registered directly in the Sharepoint system that has permissions to all the site collections (FullControl). I got the token with the app credentials from the url: https://accounts.accesscontrol.windows.net//tokens/OAuth/2 I can make requests to the Sharepoint REST API directly
Now I have to switch to an Azure registered app. The code is written in Java and I use the Azure sdk-com.microsoft.azure (artifactId-azure). I can successfully retrieve a token, but this is not valid for later requests to the Sharepoint REST API.
I get this error: 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException' was thrown."
Is there any possibility to get a valid token for Sharepoint REST API requests?