Quantcast
Channel: Authentication failed exception with MailKit OAuth2.0 - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by TheHvidsten for Authentication failed exception with MailKit OAuth2.0

$
0
0

It seems that what you want is not possible at this time. See this Github issue for details.

Basically, using ConfidentialClientApplicationBuilder can only use scopes defined as "API permissions" on your AppRegistration. If you have registered IMAP.AccessAsUser.All or Mail.Read Graph permissions, and requested them using the https://graph.microsoft.com/.default scope, you will get an access token, but it can only be used by the Graph API REST endpoints Microsoft has exposed.

MailKit does not support these Graph API endpoints (as the linked issue describes).

In order to use the IMAP support in MailKit it seems you must get an access token using PublicClientApplicationOptions as demonstrated in the MailKit example. This has the disadvantage of popping up the browser asking the user to authenticate themselves.

It is, however, uncertain how long this will work, as it seems Microsoft will deprecate their IMAP endpoints (as mentioned in the previously linked issue)


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>