I am trying to use OAuth 2.0 to connect to Office 365 Exchange for email sending. I have configured the site a shown in the documentation. I am using CMS.EmailEngine.MicrosoftExchangeOAuthProvider.
However, the Redirect URI in the documentation, https://< site domain >/CMSModules/EmailEngine/Pages/OAuth2AccessTokenDialog.aspx?redirected=1, is not allowed at Azure. Azure will not allow return URI's that have a query string.
When I request a token, the authentication popup has this in the URL
https://login.microsoftonline.com/GUID/oauth2/v2.0/authorize?client_id=XXXXX&response_type=code&state=XXXXX&scope=offline_access+https%3a%2f%2foutlook.office.com%2fPOP.AccessAsUser.All+https%3a%2f%2foutlook.office.com%2fSMTP.Send&redirect_uri=https%3a%2f%2fwww.mydomain.com%2fAdmin%2fCMSModules%2fEmailEngine%2fPages%2fOAuth2AccessTokenDialog.aspx%3fredirected%3d1
and I get this error from Microsoft
AADSTS50011: The redirect URI 'https://www.msinteractive.com/Admin/CMSModules/EmailEngine/Pages/OAuth2AccessTokenDialog.aspx?redirected=1' specified in the request does not match the redirect URIs configured for the application '0d7237f2-1874-426d-a141-933151601e5a'. Make sure the redirect URI sent in the request matches one added to your application in the Azure portal.
I tried to remove this from the URL (%3fredirected%3d1) and post report it. Microsoft then accepts the authentication, but when I redirect back to Kentico I get the error
"Credentials not found."
How can I use OAuth with Kentico 13?
----------Environment
Kentico Xperience version: [v13.0.165]
.NET version: [8]
Execution environment: [Private cloud (AWS)]
Link to relevant https://docs.kentico.com/13/configuring-xperience/configuring-smtp-servers/oauth-for-email-servers