Skip to content

imap authentication not working #78

@ajendrex

Description

@ajendrex

Hi!

I have an access token with scope https://www.googleapis.com/auth/gmail.modify and which I validated with SMTP to send emails. The same token used to try oauth2.py from this repository seems to be invalid:

python oauth2.py --test_imap_authentication --access_token=<access_token> --user=<email_address>

  18:48.35 > b'ILPK1 AUTHENTICATE XOAUTH2'
  18:48.50 < b'+ '
  18:48.50 write literal size 364
  18:49.49 < b'+ eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ=='
  18:49.49 write literal size 364
  18:49.64 < b'ILPK1 NO [AUTHENTICATIONFAILED] Invalid credentials (Failure)'
Traceback (most recent call last):
  File "/Users/hurbina/src/gmail-oauth2-tools/python/oauth2.py", line 353, in <module>
    main(sys.argv)
  File "/Users/hurbina/src/gmail-oauth2-tools/python/oauth2.py", line 338, in main
    TestImapAuthentication(
  File "/Users/hurbina/src/gmail-oauth2-tools/python/oauth2.py", line 282, in TestImapAuthentication
    imap_conn.authenticate('XOAUTH2', lambda x: auth_string)
  File "/Users/hurbina/opt/anaconda3/lib/python3.9/imaplib.py", line 444, in authenticate
    raise self.error(dat[-1].decode('utf-8', 'replace'))
imaplib.IMAP4.error: [AUTHENTICATIONFAILED] Invalid credentials (Failure)

I'd appreciate very much some help to understand what is wrong.

Hector.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions