oAuth2 Outlook Office365 & Pop3 - Client Credential Grant Flow
Ive gone through all the documentation i can find (this one is fantastic https://www.youtube.com/watch?v=bMYA-146dmM&t=609s)
But for the life of me I cannot get POP3 to work.
IMAP etc works fine. But its just plain not authenticating, I'm sure its something simple, but nothing is glaring out .
Im using MailKit.Net.Pop3 to do the connection,
var oauth2 = new SaslMechanismOAuth2(Email, Token);
using (var client2 = new MailKit.Net.Pop3.Pop3Client(new ProtocolLogger("pop3.log")))
{
//client2.AuthenticationMechanisms.Add("XOAUTH2");
await client2.ConnectAsync("outlook.office365.com", 995, SecureSocketOptions.Auto);
await client2.AuthenticateAsync(oauth2); <----- Error MailKit.Net.Pop3.Pop3ProtocolException: 'POP3 server did not respond with a +OK response to the AUTH command.'
var UIDs = client2.GetMessageUids();
await client2.DisconnectAsync(true);
}
The JWT has this scope:
"roles": [
"Mail.ReadWrite",
"POP.AccessAsApp",
"Mail.Read",
"Mail.Send",
"IMAP.AccessAsApp"
]
As said i can use the same Authentication on ImapCLient and is totally fine.
THe User has Pop3 enabled for the Email account, PLEASE HELP !!!
I really dont wat to rewrite loads of apps away from POP this close to switch over from Microsoft !!
This is the log results:
S: +OK The Microsoft Exchange POP3 service is ready. [TABPADQAUAAxADIAMwBDAEEAMAAzADAAOAAuAEcAQgBSAFAAMQAyADMALgBQAFIATwBEAC4ATwBVAFQATABPAE8ASwAuAEMATwBNAA==]
C: CAPA
S: +OK
S: TOP
S: UIDL
S: SASL PLAIN XOAUTH2
S: USER
S: .
C: AUTH XOAUTH2
S: +