aboutsummaryrefslogtreecommitdiffstats
path: root/cloud_mdir_sync/gmail.py
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@mellanox.com>2020-06-19 14:10:28 -0300
committerJason Gunthorpe <jgg@nvidia.com>2020-06-22 20:24:18 -0300
commitc607f4a3cbd9cc4c9611db12bfe175b52de514e1 (patch)
tree7d9772b095b956137cab0f17c8941fff2b33b08c /cloud_mdir_sync/gmail.py
parent6c7dbe902d8679570ca10f39672d844fa5cb6c50 (diff)
downloadcloud_mdir_sync-c607f4a3cbd9cc4c9611db12bfe175b52de514e1.tar.gz
cloud_mdir_sync-c607f4a3cbd9cc4c9611db12bfe175b52de514e1.tar.bz2
cloud_mdir_sync-c607f4a3cbd9cc4c9611db12bfe175b52de514e1.zip
OAUTH: Add support to get an IMAP OAUTH token
Latest mutt can do this for MS and GMail providers, provide support for getting the right scope and some examples how to set it up. Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'cloud_mdir_sync/gmail.py')
-rw-r--r--cloud_mdir_sync/gmail.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/cloud_mdir_sync/gmail.py b/cloud_mdir_sync/gmail.py
index dc70361..20e7502 100644
--- a/cloud_mdir_sync/gmail.py
+++ b/cloud_mdir_sync/gmail.py
@@ -89,7 +89,7 @@ class GmailAPI(oauth.Account):
self.scopes = [
"https://www.googleapis.com/auth/gmail.modify",
]
- if self.oauth_smtp:
+ if "SMTP" in self.protocols or "IMAP" in self.protocols:
self.scopes.append("https://mail.google.com/")
self.redirect_url = cfg.web_app.url + "oauth2/gmail"
@@ -263,13 +263,13 @@ class GmailAPI(oauth.Account):
async def close(self):
await self.session.close()
- async def get_xoauth2_bytes(self, proto: str) -> bytes:
+ async def get_xoauth2_bytes(self, proto: str) -> Optional[bytes]:
"""Return the xoauth2 byte string for the given protocol to login to
this account."""
while self.api_token is None:
await self.authenticate()
- if proto == "SMTP":
+ if proto == "SMTP" or proto == "IMAP":
res = 'user=%s\1auth=%s %s\1\1' % (self.user,
self.api_token["token_type"],
self.api_token["access_token"])