In the past I have successfully been able to access my Gmail account using curl in bash or zsh shell scripts, like this:
USERNAME='example@gmail.com'
PASSWORD='superSeckret'
URL='https://mail.google.com/mail/feed/atom'
curl -s -u "$USERNAME:$PASSWORD" "$URL"
However, now when I attempt this, I get this error:
<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
If I open https://mail.google.com/mail/feed/atom in a web browser, it shows the feed as expected, but I cannot get it to work via curl.
I tried looking to see if Google had shut down access to this, but I did not see anything that seemed relevant, but I still can't get it to work.
Is there another way to try this?
At minimum what I would like is to get a count of unread messages in my Gmail inbox.
Being able to see the From: and Subject: lines would also be nice.
(I have tried this both from my regular Gmail account as well as my work email which is a Google Suite/Google Apps address which has support for 'less secure apps' enabled. I am actually trying to do this for my work email.)
Any help would be appreciated.