I have not found a solution that allows the current Mailpile version to access GMail via IMAP. This includes some efforts to use application passwords and two-factor authentication.
I have searched the Google support pages for a clear statement of what Google is doing without any results. The closest that I have come is this page (applicable only to G-Suite users) which indicates that “Less secure apps” will be disabled completely as of 2021-02-15. I can’t find any similar statement or timetable for ordinary GMail users. My guess is that Google has decided to eliminate “less secure apps” and has done so, essentially without notice, for ordinary users of free GMail accounts, but has provided a year advance notice to its business users to avoid upsetting them.
So it appears that, unless or until someone is able to devote considerable time to navigating Google’s increasingly onerous obstacle course to get Mailpile “verified”, Mailpile cannot be used as a client for GMail accounts. Of course, this applies to any small, volunteer run “free as in speech” email client; indeed, it even would be an issue for a small commercial startup. Which of course, enhances GMail’s market share and user lock-in. Funny about that.
Strangely enough, I have one gmail account that I created a long time ago, whose IMAP interface continues to be accessible to Mailpile, although other old accounts have become inaccessible (and of course no new account is accessible). I’m guessing I turned on “less secure apps” for that account when Google first started limiting use of that option; more recently, even though the option is turned on, it has no effect.