Re-order requested scopes

Created on 23 January 2023, almost 2 years ago

Problem/Motivation

I was having trouble authenticating using OAuth2 over SMTP from the token generated.

All creds were correct, tokens generated without error and, according to my colleague handling the Azure config, app scopes were appropriately granted.

After lots of troubleshooting with related issues, I found this wiki for PHPMailer:
https://github.com/PHPMailer/PHPMailer/wiki/Microsoft-OAuth2-SMTP-issues

Whilst the wiki goes into more detail, since MS' changes to APIs and semi-retiring the Outlook REST API, the order of requested scopes now matters even when the scopes are fully namespaced.

Steps to reproduce

  1. Setup following instructions with Azure app with correct scopes and without legacy use of the Outlook REST API
  2. Generate token
  3. Attempt to send mail using SMTP OAuth2 with generated token
  4. Authentication unsuccessful

Proposed resolution

Reorder requested scopes so that https://outlook.office.com/SMTP.Send scope comes before offline_access.

I will follow up this with work on an issue fork.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024