def oauth_login(self, url, oauth_token, oauth_token_secret,
consumer_key='anonymous', consumer_secret='anonymous'):
"""Authenticate using the OAUTH method.
This only works with IMAP servers that support OAUTH (e.g. Gmail).
"""
if oauth_module:
token = oauth_module.Token(oauth_token, oauth_token_secret)
consumer = oauth_module.Consumer(consumer_key, consumer_secret)
xoauth_callable = lambda x: oauth_module.build_xoauth_string(url,
consumer,
token)
return self._command_and_check('authenticate', 'XOAUTH',
xoauth_callable, unpack=True)
else:
raise self.Error(
'The optional oauth2 package is needed for OAUTH authentication')
评论列表
文章目录