IMAP-Zugriff auf den Google Mail-Posteingang mit XOAUTH

Ich folge demBeispie, Ich habe meine Anwendung bereits autorisiert (= habe das Zugriffstoken erhalten), aber der Versuch, auf den Posteingang zuzugreifen, führt zu folgenden Ergebnissen:

  21:14.12 > NDIB1 AUTHENTICATE XOAUTH
  21:14.17 < + 
  21:14.17 write literal size 480
  21:14.74 < NDIB1 NO [ALERT] Invalid credentials (Failure)
  21:14.74 NO response: [ALERT] Invalid credentials (Failure)

Dies ist der Code:

import xoauth
import oauth2 as oauth
import imaplib

consumer = oauth.Consumer('anonymous', 'anonymous')
access_token = oauth.Token(my_access_token, my_access_token_secret)
user = my_gmail_address
proto = "imap" # is it right???
xoauth_requestor_id = user # and this???
xoauth_string = xoauth.GenerateXOauthString(consumer, access_token, user, proto, xoauth_requestor_id, '', '')
conn = imaplib.IMAP4_SSL('imap.googlemail.com')
conn.debug = 4
conn.authenticate('XOAUTH', lambda x: xoauth_string)
conn.select('INBOX')
print conn.list()

Es schlägt beim Aufruf von conn.authenticate () fehl. Irgendeine Idee

Antworten auf die Frage(2)

Ihre Antwort auf die Frage