dev/mail#79 - Fix MS Exchange/IMAP. Use OpenID Connect. #18951
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This addresses a bug (https://lab.civicrm.org/dev/mail/-/issues/79) where the OAuth2 implementation does not work with MS Exchange Online's IMAP.
Before
When requesting a token for the
ms-exchange
provider, Civi requests multiple permissions, includingUser.Read
(to determine the default email address) andIMAP.AccessAsUser.All
(to connect the relevant mailbox).Thanks to @demeritcowboy's debugging, we can see there is a problem in Microsoft's services: it treats these permissions as mutually-exclusive. (If you have
User.Read
permission, thenIMAP.AccessAsUser.All
does not work.)After
Stop requesting
User.Read
permission. Consequently, we can't read the default email address fromhttps://graph.microsoft.com/v1.0/me
. Instead, we can use OpenID Connect to determine the email address.Comments
Tested in local builds of 5.32.beta with both:
dmaster
- Apply patch and flush caches. Register a new "Mail Account" and run "Save & Test".