I am trying to send Mails via SMTP OAuth2 from Office365 Accounts. I have created a non verified Multitenant Application in Microsoft Entra admin center.
I have registered following permissions for the app: Configured permissions
But use following scopes in the Token Endpoint (https://login.microsoftonline.com/common/oauth2/v2.0/token):
- https://outlook.office365.com/IMAP.AccessAsUser.All
- https://outlook.office365.com/SMTP.Send
- offline_access
Unfortunately I have not been able to find clear information, why there are differences in the scopes between the app registration and the Token request. But this workflow is successful while using an Office Account from my own tenant.
I have tried the same workflow with an Account from a different tenant. I do not get any problems while executing the OAuth2 and receive a working Token and RefreshToken, but when I try to send the Mail via MailKit Plugin I get following error: The server has rejected authentication data sent by the client. The server responded: 535 5.7.3 Authentication unsuccessful [VI1PR04CA0056.eurprd04.prod.outlook.com 2023-11-14T09:51:21.804Z 08DBE3A286C51277].
Does anyone have experience with Office365 SMTP OAuth and could provide help in fixing this issue?