Task Factory Error When Using Oath2 Connection Manager to Connect to Office 365

We're getting the following error when trying to connect to Office 365 using Task factory and an Azure app.

[TF Email Source] Error: DEBUG (PrimeOutput): An error occurred during processing email: Authentication failed.
Failed to ensure transaction state.

Scopes are probably overboard for what we need but here's what we have:

It connects successfully when using Mail Protocol: SMTP but not POP or IMAP.

Any help would be greatly appreciated.