Cannot connect to IMAP and SMTP using OAuth2.0 to Exchange Online
发布时间:2026-09-17 | 浏览:1
Forum Discussion
Last week the support for IMAP and SMTP using OAuth2.0 has been announced.
Following https://docs.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth, I added the required API permissions to Azure App Registration and tried to connect, but it didn't work.
I get this error for IMAP:
And this one for SMTP:
The more detailed summary I have submitted to the https://stackoverflow.com/q/61597263/1126831, please check it for more in-depth details.
Can someone please from the Exchange team look into this?
It appears, that when requesting the following scopes everything works as expected:
With these scopes, the token is generated, but IMAP and SMTP auth fails:
And when requesting these:
I get the following error:
ledniov May 17, 2020 A quote of the Stack Overflow reply from: IMAP, SMTP scopes are targeted for Exchange resource and not Graph. Whereas User.Read, Mail.ReadWrite are meant for Graph resource. We do not support generation of tokens that are meant for two resources. Hence the error "Provided value for the input parameter scope is not valid because it contains more than one resource." You should generate two tokens separately by two calls to /token. 1. One with the IMAP, SMTP scopes generated for the Exchange resource. 2. The other with Graph scopes (User.Read, Mail.ReadWrite) meant for Graph resource. https://stackoverflow.com/a/61678485/1126831 Marked as Solution
A quote of the Stack Overflow reply from:
IMAP, SMTP scopes are targeted for Exchange resource and not Graph. Whereas User.Read, Mail.ReadWrite are meant for Graph resource.
We do not support generation of tokens that are meant for two resources. Hence the error "Provided value for the input parameter scope is not valid because it contains more than one resource."
You should generate two tokens separately by two calls to /token. 1. One with the IMAP, SMTP scopes generated for the Exchange resource. 2. The other with Graph scopes (User.Read, Mail.ReadWrite) meant for Graph resource.
https://stackoverflow.com/a/61678485/1126831