When this issue first came up a few years ago I decided to take a different approach, and wrote a proxy that sits between your IMAP/POP/SMTP client and the OAuth email provider. This way, you don't need to modify your client code, and only have to handle interactive OAuth requests once per account. You can find it here: https://github.com/simonrob/email-oauth2-proxy.