Developer Guide
4 min read · Updated 2026-12-01
How to Connect Hotmail & Outlook IMAP with OAuth2 Refresh Tokens in Python
Step-by-step Python 3 guide to exchanging Microsoft OAuth2 refresh_token and client_id for an access token and reading Hotmail/Outlook mail via imaplib XOAUTH2.