rcarmo/imapbackup

Authentication Fails with Complicated Password String

Closed this issue · 3 comments

I'm attempting to run imapbackup on my Gmail account (IMAP has been enabled already), but am running into an issue as my password is long with many special characters in it, and I keep getting authentication failed.

These are the IMAP settings for Gmail (once you've enabled IMAP in your Settings > See all settings > Forwarding and POP/IMAP > Enable IMAP):

image

The command I'm trying to run, using these settings, looks like this (note password and email have been changed, so this will not work as is, but simulates what I'm attempting):

python imapbackup38.py --folders="Starred" --ssl --server="imap.gmail.com" --user="fakeemail@gmail.com" --pass="qN03s@dSGabr33%pQjW@re%tqNIf&c^M4JDbl!Czx$v$r1GVI#@wTr^AwTbfdkglX"

This results in an output that looks like:

Connecting to 'imap.gmail.com' TCP port 993, SSL
Logging in as 'fakeemail@gmail.com'
ERROR: b'[AUTHENTICATIONFAILED] Invalid credentials (Failure)'

I have tried the following commands with the same issue:

Putting an r before the password string

python imapbackup38.py --folders="Starred" --ssl --server="imap.gmail.com" --user="fakeemail@gmail.com" --pass=r"qN03s@dSGabr33%pQjW@re%tqNIf&c^M4JDbl!Czx$v$r1GVI#@wTr^AwTbfdkglX"

Escaping all special characters in the string

python imapbackup38.py --folders="Starred" --ssl --server="imap.gmail.com" --user="fakeemail@gmail.com" --pass="qN03s\@dSGabr33\%pQjW\@re\%tqNIf\&c\^M4JDbl\!Czx\$v\$r1GVI\#\@wTr\^AwTbfdkglX"

How can I get it to parse this kind of password string?

Gmail has been blocking access to IMAP with “normal” passwords and requiring OAuth authentication. It used to be possible to define an “application password” someplace in the account security settings, but I tried to do that only last week and the option was removed from one of my accounts — I suggest checking yours.

Yeah I think Gmail has made a change to using OAuth and there's some steps required in creating an app with the Gmail API. I started trying to use this package that attempts to automate that process, but even it is having problems. Interesting.

I think you still can have application passwords, but you must enable 2FA on the GMail account (at least I'm logging in like that with my normal Apple Mail client going over stunnel for up-to-date SSL). Either way Google with their market dominance gives a 💩 about standards and compatibility.