Python imaplib Gmail authenticate failure
Asked Answered
P

4

8

I just ran into an issue with Python's imaplib and Gmail's authentication mechanism:

>>> import imaplib
>>> imap = imaplib.IMAP4_SSL('imap.gmail.com', 993)
>>> imap.authenticate('[email protected]', 'Bob Dole likes your style!')
Traceback (most recent call last):
  ...
imaplib.error: AUTHENTICATE command error: BAD ['TODO (not supported yet) 31if3458825wff.5']

If authentication is unsupported, how does one log in?

Palladic answered 9/12, 2008 at 6:7 Comment(0)
B
8

Instead of

>>> imap.authenticate('[email protected]', 'Bob Dole likes your style!')

use

>>> imap.login('[email protected]', 'Bob Dole likes your style!')
Boswell answered 9/12, 2008 at 6:10 Comment(0)
T
3

The following works for me:

srv = imaplib.IMAP4_SSL("imap.gmail.com")
srv.login(account, password)

I think using login() is required.

Tabbitha answered 9/12, 2008 at 6:10 Comment(0)
P
0

I found the solution on this helpful blog post. Although Gmail doesn't support AUTHENTICATE, it does support the LOGIN capability, like so:

>>> imap.login('[email protected]', 'Bob Dole likes your style!')
('OK', ['[email protected] authenticated (Success)'])
Palladic answered 9/12, 2008 at 6:8 Comment(0)
H
0

This will work in Python

import imaplib imap = imaplib.IMAP4_SSL('imap.gmail.com', 993) imap.login('[email protected]', 'Bob Dole likes your style!')

You don't necessarily need to use the port number also, creating the imap Session will also work like: imap = imaplib.IMAP4_SSL('imap.gmail.com')

Higinbotham answered 5/4, 2018 at 7:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.