Comments (4)
Hello, do you know the service where I can check this method?
from aioimaplib.
Normally every server compliant with rfc3501 should implement this.
I've seen lines like this :
2018-05-09 10:00:41,006 DEBUG [aioimaplib:312] Received : b'* CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE AUTH=PLAIN AUTH=LOGIN\r\nGEHP0 OK Pre-login capabilities listed, post-login capabilities have more.\r\n'
2018-05-09 10:00:41,006 DEBUG [aioimaplib:598] tagged status GEHP0 OK Pre-login capabilities listed, post-login capabilities have more.
With orange.fr, outlook.com, yahoo.com, gmail.com, free.fr
I'd say that whenever a server says SASL-IR
as capability means it supports rfc-4959 so the AUTHENTICATE
method.
from aioimaplib.
Please add this. it is extremely important nowadays with e.g. Microsoft requiring XOAUTH2.
from aioimaplib.
FYI here's a very ugly implementation that works. Proper upstream support would be nicer of course :)
class IMAP4ClientProtocolWithXOAUTH2(IMAP4ClientProtocol):
def __init__(self, loop, conn_lost_cb=None):
super().__init__(loop, conn_lost_cb)
self.literal_auth_data = None
def _continuation(self, line: bytes) -> None:
if self.pending_sync_command and self.pending_sync_command.name == 'AUTHENTICATE':
if self.literal_auth_data is None:
Abort('asked for literal auth data but have no literal auth data to send')
self.transport.write(self.literal_auth_data)
self.transport.write(CRLF)
self.literal_auth_data = None
return
super()._continuation(line)
@change_state
async def authenticate(self, mechanism: str, data: str):
self.literal_auth_data = base64.b64encode(data.encode('ascii'))
response = await self.execute(Command('AUTHENTICATE', self.new_tag(), mechanism, loop=self.loop))
if 'OK' == response.result:
self.state = AUTH
for line in response.lines:
if b'CAPABILITY' in line:
self.capabilities = self.capabilities.union(set(line.decode().replace('CAPABILITY', '').strip().split()))
return response
class IMAP4WithXOAUTH2(IMAP4):
def create_client(self, host, port, loop, conn_lost_cb=None, ssl_context=None):
local_loop = loop if loop is not None else get_running_loop()
self.protocol = IMAP4ClientProtocolWithXOAUTH2(local_loop, conn_lost_cb)
local_loop.create_task(local_loop.create_connection(lambda: self.protocol, host, port, ssl=ssl_context))
async def authenticate(self, mechanism: str, data: str):
return await asyncio.wait_for(self.protocol.authenticate(mechanism, data), self.timeout)
class IMAP4WithXOAUTH2_SSL(IMAP4WithXOAUTH2):
def __init__(self, host = '127.0.0.1', port=993, loop=None, timeout=IMAP4.TIMEOUT_SECONDS, ssl_context=None):
super().__init__(host, port, loop, timeout, None, ssl_context)
def create_client(self, host, port, loop, conn_lost_cb=None, ssl_context=None):
if ssl_context is None:
ssl_context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
super().create_client(host, port, loop, conn_lost_cb, ssl_context)
Used like this:
with open(oauthfile, 'r') as tokenfile:
oauthdata = 'user={}\1auth=Bearer {}\1\1'.format(user, f.read().strip())
await imap_client.authenticate('XOAUTH2', oauthdata)
from aioimaplib.
Related Issues (20)
- Published IDLE example failing with Python 3.9 HOT 1
- Python 3.9 - Task exception was never retrieved HOT 1
- Office365 append pending forever
- imapserver.py example
- STOP_WAIT_SERVER_PUSH is str not bytes
- The example in the README.rst shows a different behaviour from what happens on my system HOT 1
- How to handle literals in FETCH response HOT 5
- SCRAM-SHA-1(-PLUS) + SCRAM-SHA-256(-PLUS) + SCRAM-SHA-512(-PLUS) + SCRAM-SHA3-512(-PLUS) supports
- Speed of aioimaplib HOT 1
- Not compatible with python 3.10 HOT 3
- test_get_quotaroot fails HOT 1
- Py 3.10: ssl.SSLError: Cannot create a client socket with a PROTOCOL_TLS_SERVER context HOT 7
- Release Bump to 1.0.1 HOT 3
- Fix compatibility with Python 3.10+ HOT 2
- Check for BYE response
- How use proxy? HOT 1
- SSLError not thrown by the client
- Bump release with xoauth? HOT 2
- login() method logs passwords HOT 2
- How to read e-mail content? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aioimaplib.