[Users] claws-mail with OAuth2 IMAP O365

Philippe Cara (TB) philippe.cara at vub.be
Tue Jan 16 16:32:25 UTC 2024


Dear claws-friends,

I am writing a long e-mail in the hope that someone will find where I
go wrong in trying to use claws-mail to read/send e-mail via the O365
environment of my university, using OAuth2. I have no permissions on
the Azure server to create a client-ID and secret for claws-mail. So
the idea is to pretend that I am using Thunderbird.

I already got a lot of suggestions from this mailing list. Thank you all 
for that! I feel I am close to success but I still need some help.

SETUP: Linux Debian 12 Bookworm + Claws-mail 4.1.1

CLAWS SETTINGS: (everything I don't mention keeps default value)
*Basic: Name of account  = O365; Protocol = IMAP;
    Server for receiving = outlook.office365.com;
    SMTP server (Send) = smtp.office365.com;
    User ID = philippe.cara at vub.be; Password = <empty>
*Receive: only changed Authentication method to OAUTH2
*Send: SMTP Authentication = on; Authentication method = OAUTH2
*TLS: IMAP: Use TLS; Send (SMTP): Use STARTTLS; Use non-blocking TLS = on
*OAuth2: Select OAuth2 Email Service Provider = MS Outlook (also tried
    MS Exchange); Client ID = 9e5f94bc-e8a4-4e73-b8be-63364c29d753;
    Client secret = <empty>; [Clicked "Copy link", then pasted it into
    Firefox, changed "redirect_uri=http%3A%2F%2F127.0.0.1%3A8888" into
    "redirect_uri=https%3A%2F%2Flocalhost", I went through all the
    2-factor authentication and got the "Unable to connect" page in
    Firefox, copied the URL from the address box and pasted it into
    Authorization code, then clicked "Authorize"]
*Advanced: Checked SMTP port and changed port to 587; Checked IMAP port
    but left it on 993.

FROM NETWORK LOG:
* Account 'O365': Connecting to IMAP server: outlook.office365.com:993...
[2024-01-16 13:35:34] IMAP< * OK The Microsoft Exchange IMAP4 service is 
ready. [QQBT... long string]
* IMAP connection is un-authenticated
* OAuth2 trying for fresh access token with authorization code
* OAuth2 missing authorization code
* OAuth2 access token not obtained
[2024-01-16 13:35:39] IMAP> 1 CAPABILITY
[2024-01-16 13:35:39] IMAP< * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN 
AUTH=XOAUTH2 SASL -IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+
[2024-01-16 13:35:39] IMAP< 1 OK CAPABILITY completed.
[2024-01-16 13:35:39] IMAP> Logging philippe.cara at vub.be to 
outlook.office365.com using XOAUTH2
[2024-01-16 13:35:40] IMAP< AUTHENTICATE failed.
** IMAP error on outlook.office365.com: LOGIN error
[2024-01-16 13:35:40] IMAP< Error logging in to outlook.office365.com
[2024-01-16 13:35:51] IMAP> 10 NOOP
[2024-01-16 13:35:51] IMAP< 10 OK Success

... tried again to Get mail. Had to type my password ...

[2024-01-16 13:36:00] IMAP> Logging pcara at vub.be to 
outlook.office365.com using XOAUT2
[2024-01-16 13:36:00] IMAP< AUTHENTICATE failed.
** IMAP error on outlook.office365.com: LOGIN error
* OAuth2 access token not obtained
* OAuth2 refresh token not obtained
[2024-01-16 13:36:00] IMAP< Error logging in to outlook.office365.com
[2024-01-16 13:36:05] IMAP> 4 LOGOUT
[2024-01-16 13:36:05] IMAP< * BYE Microsoft Exchange Server IMAP4 server 
signing off.
[2024-01-16 13:36:05] IMAP< 4 OK LOGOUT completed.

WHEN I CLICK "AUTHORIZE" IN "OAUTH2" SECTION:
* OAuth2 access token not obtained
* OAuth2 refresh token not obtained
[2024-01-16 13:36:51] IMAP> 11 NOOP
[2024-01-16 13:36:51] IMAP< 11 OK Success
[2024-01-16 13:37:51] IMAP> 12 NOOP
[2024-01-16 13:37:51] IMAP< 12 OK Success

Any help or suggestion is welcome!

Cheers,					--Philippe


More information about the Users mailing list