Interesting. I just tried to find the announcement from Google where
they said app specific passwords for imap/smtp were going to be removed
and now cannot find it. Google originally said they were going to remove
all password based access and only support oauth2 by mid 2021. This was
later postponed due to the pandemic.
There were some lengthy threads about this in emacs-devel i late 2020
and early 2021.
Looking at what Google currently has up, it seems they are now
suggesting that if you have to use applicaitons which don't support
oath2, you can use an app password.
Due to Google's policy regarding oauth2 apps needing to be vetted by
Google and the requirement that any oaht2 toeksn not being visible to
end users, there was a real issue for open source applications wanting
to support oauth2. With oauth2, you have an application 'token'
(misleadingly called a secret in oath2 terminology), which is used to
identify a specific application. The idea being, if google foudn a
specific application had a vulnerability, it could lock out just that
application easily/quickly.
There are 2 ways to get an application token. The main way is to have
your application registered with google (think mbsync for example). The
other way is to register as a developer and get a developer app toeken
(anyone can do this, but it is a bit of a pain). The problem for open
source software is that they cannot embed the application token in the
source code as it has to remain a secret to comply with Google's T&C.
My guess is that Google has perhaps decided to leave app passwords in
place as a work-around for open source apps - at least for the time
being.
The threads on emacs-devel had some details on how to setup smtp and
oauth2 and there was some sketchy details on how you could use mbsync
and other prorams, provided they were built with SASL support.
I believe some applications, like possibly Thunderbird and Mutt, have
ignored the Google T&C and have put an application token into their code
in order to have it work without the need for app passwords. I've not
verified this.
The other solution mentioned in the emacs-devel threads was to use a
proxy service i.e. davMail as a gateway. This can work well if you need
to access both gmail and office365.