Custom OAuth internet account on macOS - is it possible?

My e-mail server supports OAuth for login. It would be nice to replace username/password with a OAuth, the same way that other accounts such as Microsoft Exchange, Google, etc, work.

Is there a framework that allow me to implement such thing? Like a custom internet account in addition to vanilla imap and the others provided by Google, Microsoft, Yahoo, etc?