I honestly have no idea how it works. I thought that the Mail app would login once, and store some sort of 30-day auth token.
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH
250-AUTH LOGIN PLAIN XOAUTHMy point still stands though, which is that you can use IMAP without passwords.