I want to send emails via smtp with an oauth2 token. But I always get the following error message: "Authentication unsuccessful".
Steps I have done:
- I registered an app in the Azure panel.
- Added the following permissions:
https://graph.microsoft.com/User.Read
First question here: Where can i find the permission https://outlook.office.com/SMTP.Send? Mentioned in https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth
Enabled "Authenticated SMTP" in the Microsoft Admin Center for the specific user.
I have recieved a token using the following endpoint: "https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token" with the grant type: client_credentials. With the grant type client_credentials i can only use a default scope.
and followed this tutorial: https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth#smtp-protocol-exchange
And then authenticate myself, but got the following error message: "Authentication unsuccessful"