File: oauth2_example.py

package info (click to toggle)
python-imapclient 3.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 668 kB
  • sloc: python: 5,355; sh: 14; makefile: 11
file content (14 lines) | stat: -rw-r--r-- 333 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Login using OAUTH2

from imapclient import IMAPClient

# Populate these with actual values
OAUTH2_USER = "..."
OAUTH2_ACCESS_TOKEN = "..."

HOST = "imap.host.com"
URL = "https://somedomain.com/someuser/imap/"

with IMAPClient(HOST) as server:
    server.oauth2_login(URL, OAUTH2_USER, OAUTH2_ACCESS_TOKEN)
    # ...do something...