If you can't switch to OAuth, you can simply create an app password and continue using that as your IMAP password as usual.
Edit: that's incorrect, see replies.
-- Google, when you make an App Password
(Remind me, what's stopping me from extracting the client secrets from the compiled binary, and re-using them elsewhere?)
I wonder if any intentional limitation here should not trigger some of the EU Digital Services Act provisions for interoperability ... in this list [1] I see Google Play, Maps, and Shopping but not GMail!
[1] https://en.wikipedia.org/wiki/Digital_Services_Act#Very_larg...
As the readme explains, there's nothing to stop you using the existing OAuth client details from another source (such as the many already trusted open source email clients that exist).
There is likely a package/library for your language of choice to do a basic oauth client.