There are many sample codes including Google Quickstart. I have downloaded credentials. I get the auth error
Certificate failure for [login to view URL]: self signed certificate: /OU=No SNI provided; please fix your client./CN=[login to view URL] ... using No Auth gives another error ... Can not authenticate to IMAP server: [ALERT] Application-specific password .. tried this [login to view URL]
This is clearly a google account issue...so you'll need to work in Team View so I can provide passwords as you correct settings.