outlookoffice365microsoft-graph-apioutlook-restapi

Outlook 365 OAuth 535 5.7.3 Authentication unsuccessful


I'm trying to send an email via smtp.live.com using an OAuth token generated via https://login.microsoftonline.com/common/oauth2/v2.0/… but I'm receiving the following error:

535 5.7.3 Authentication unsuccessful

I can make it work by obtaining an auth token via https://login.live.com/oauth20_authorize.srf (a legacy API) but that only works for free Microsoft accounts (I need to support business/Outlook365 accounts too).

The fact I can make it work using that legacy endpoint seems to validate that:

The access token seems valid (it works for other calls, including sending an email via the Graph API).

I've requested the following scopes:

[
  'offline_access', 'User.Read', 'MailboxSettings.ReadWrite',
  'Mail.Send', 'Mail.ReadWrite', 'Mail.Read', 'Mail.ReadBasic', 'Contacts.ReadWrite',
  'Mail.Read.Shared', 'Mail.ReadWrite.Shared', 'Mail.Send.Shared', 'MailboxSettings.Read',
  'profile', 'openid', 'email', 'Calendars.ReadWrite',
  'EAS.AccessAsUser.All', 'EWS.AccessAsUser.All',
];

For the legacy token (the one which works), the scopes are different:

[
  'wl.emails', 'wl.offline_access', 'wl.imap'
];

(I've tried including these scopes when requesting the v2 token too, but it's invalid).

Other things I've tried:


Solution

  • Office 365 SMTP servers do not support OAuth authentication as of this time.