Using OAuth2 for Gmail IMAP
kvdesai opened this issue · 6 comments
Great work!
I am trying to use this tool to upload my emails from Thunderbird (68.10) on Ubuntu 18.04 to Gmail (Google Worksapce). While setting up Thunderbird for Gmail (IMAP), I realized that Gmail nowadays only allows authentication via OAuth2. Because of this reason, when I try this script with --username and --password it fails with the following error:
Connecting to imap.gmail.com:993. IMAP4 error: [AUTHENTICATIONFAILED] Invalid credentials (Failure)
Is there a workaround?
That's interesting. I wonder if others will have similar problems. So you can't log in on Thunderbird either?
You can try an app-specific password:
Thanks for the blazing fast reply!!
I can login on Thunderbird, because it allows OAuth2. The first time I try to read message after logging in, it opens up the OAuth2 login screen where I need to type in the password. Then Thunderbird is able to pull in the messages.
App-specific password looks promising. It requires 2-step verification, but I think I can set that up. Will definitely try that.
Please let me know if the app passwords work.
Gmail nowadays only allows authentication via OAuth2
Can you clarify if this is a new thing? Did the script work for you before this change?
App-specific passwords worked for me perfectly. I was able to upoload to Gmail and Timestamps and attachments are all preserved!
This workaround may not work for Google Workspace users if for their org, the 2-step verification is not enabled by the Admin.
I am using this script for the first time. As others were able to use it without OAuth2, I assumed it was anew thing :-)
Glad we could get that fixed for you. Closing as there doesn't seem like there is any further action required on this.