For OAUTH2, I recommend starting pizauth (https://github.com/ltratt/pizauth) as a user systemd unit.
Then you can just do (eg. in mbsync)
PassCmd "pizauth show accountname"