Hello Axel von Leitner,
Thanks for posting!
Generally, this error comes when the application doesn't have the required scope on the resource.
The Mail.ReadWrite permissions exists as both delegated as well as application permission. Please ensure you have consented the correct set of permissions in Azure AD application based on the authentication flow. Refer Mail permissions.
Secondarily, in case you are using auth URL like this: https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=%@&scope=%@&response_type=code&redirect_uri=%@
, then you have to separate the scopes using a space rather than a comma. When using multiple scopes in the authentication request, the scopes must be separated with a space. Otherwise, it'll treat all the scopes as a single string " mail.readwrite,User.Read,offline_access
" and doesn't match with any of the scopes added to the application. If you separate the scopes using space, mail.readwrite User.Read offline_access
the scopes won't be concatenated and will be treated as individual scopes.
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.