Office365 account disconnects (only the account that needs two-factor authentication)

Description

My office365 account disconnects at least twice a day and every morning I have to reconnect since I updated to version 1.8.0 on my mac (this problem occurs in my Linux machine as well).

This only occurs in the account the needs the two-factor authentication. The latest version of Mailspring (1.8.0) allows me to log in, but as I said, it gets disconnected all the time.

To Reproduce…

Steps to reproduce the behavior:

  1. Open Mailspring and wait long enough (sometimes a couple of hours) or send your laptop to sleep and next time you open it, the account is disconnected again

Expected Behavior

I expect my account to stay connected like the other accounts.

Screenshots

Setup

  • OS and Version: macOS 10.14.6, Ubuntu Linux 20.04
    • Installation Method: installer, .deb
  • Mailspring Version: 1.8.0

Additional Context

I understand the two-factor authentication might be problematic, but having to reconnect constantly is an important issue that needs to be fixed.

I have exactly the same problem with my college email account. My Gmail account stays connected, but every time I wake my laptop, Mailspring requires me to manually reconnect to my college account, which uses Office 365. This doesn’t happen with Thunderbird, which stores my login credentials.

The only difference I have from the OP is that my college email doesn’t use two-factor authentication.

3 Likes

Don’t forget to vote for this issue as well. It helps improve its priority.

2 Likes

UPDATE:

Now I can’t even connect to my Office365 account anymore. This is making Mailspring useless for me since my institutional email is my most important email account.

If the issues with Office365 persist (they’ve been going on for months now). I’m going to stop paying for Mailspring Pro (I really like the product and want to contribute to this nice project but I can’t afford to pay for a product that is not useful).

1 Like

Yeah Office365 accounts haven’t been useable in while (see other posts in the forum), right now the project is in transition to be fully OSS and we’re all kind of just waiting for the next release. Hang in there if you can!

4 Likes

Same issue for me. Windows 10 Student Edition. University recently switched to Office365 and even more recently implemented 2FA. My iPhone mail client(native iOS mail app) doesnt have this issue. I wonder if there is a permission issue happening. I’ll try to reach out to microsoft first, and then my uni. I doubt my uni will remove 2FA for me.

Description

Mailsprint asks to reconnect to office 365 every single time it starts up.

To Reproduce…

Steps to reproduce the behavior:

Add office 365 account and sync mail. Quit Mailspring. Restart. It asks again to Reconnect. Reconnect. Sync. Quit Mailspring. Restart. Again. Loop back to the beginning. Unusable.

Expected Behavior

It should ask once and never again till the password changes.

Setup

  • OS and Version: macos 10.14.6 (18G8022)
    • Installation Method: r u kidding? u think ppl remember this?
  • Mailspring Version: Version 1.8.0 (1.8.0)
1 Like

I have this exact issue for two university office 365 accounts. Within browser I get an option to not ask for the second factor of authentication for 14 days. However, for mailspring it seems to last only hours before I get disconnected.

I should say this has made me stop using mailspring for now. It’s too much hassle to constantly log in again.

1 Like

Having the exact same issue… I need this for my work place, so pleeaaase look into this…

This an issue for me as well. Are there any plans on getting this sorted?

Are there any plans on getting this sorted?

This is basically all volunteer-driven development. Even the main developer, Ben, does this in addition to a full-time job. We do hope to address it, and will post here when we actually start work. (Asking won’t hurry it along, just FYI.)

I’ve a little bit more information. I’ve three exchange accounts, one with 2fa and two not. All three expire after a day. The problem is with the mailsync some where around the XOAuth2TokenManager and MakeOAuthRefreshRequest. Here is the error I get:

172816 [2021-05-06 17:14:00.336] [background] [info] Sync loop complete.
172816 [2021-05-06 17:14:01.070] [metadataExpiration] [info] Scanning for expired metadata
172816 [2021-05-06 17:14:01.070] [metadataExpiration] [info] -- Will wake for next expiration in 7200sec
172816 [2021-05-06 17:54:43.890] [background] [info] Fetching XOAuth2 access token (office365) for 78406ad9
172816 [2021-05-06 17:54:44.361] [background] [critical] 
***
*** Mailspring Sync 
*** An exception occurred during program execution: 
*** {"debuginfo":"https://login.microsoftonline.com/common/oauth2/v2.0/token","key":"Couldn't resolve host name","retryable":true,"what":"std::exception"}
***

172816 [2021-05-06 17:54:44.361] [background] [info] --sleeping
172816 [2021-05-06 17:55:51.384] [main] [info] Waking all workers...
172816 [2021-05-06 17:55:51.384] [background] [info] Fetching XOAuth2 access token (office365) for 78406ad9
172816 [2021-05-06 17:55:51.389] [foreground] [info] Idle exited with code 1
172816 [2021-05-06 17:55:51.741] [foreground] [info] Fetching XOAuth2 access token (office365) for 78406ad9
172816 [2021-05-06 17:55:51.741] [background] [critical] 
***
*** Mailspring Sync 
*** An exception occurred during program execution: 
*** {"debuginfo":"https://login.microsoftonline.com/common/oauth2/v2.0/token RETURNED {\"error\":\"invalid_grant\",\"error_description\":\"AADSTS700081: The refresh token has expired due to maximum lifetime. The token was issued on 2021-05-05T15:10:49.0974195+00:00 and the maximum allowed lifetime for this application is 1.00:00:00.\\r\\nTrace ID: 89811100-d149-4b0d-8f9f-70172626a400\\r\\nCorrelation ID: 5441121c-e3e2-4435-b2ef-c80a2e2fcd65\\r\\nTimestamp: 2021-05-06 15:55:51Z\",\"error_codes\":[700081],\"timestamp\":\"2021-05-06 15:55:51Z\",\"trace_id\":\"89811100-d149-4b0d-8f9f-70172626a400\",\"correlation_id\":\"5441121c-e3e2-4435-b2ef-c80a2e2fcd65\",\"error_uri\":\"https://login.microsoftonline.com/error?code=700081\"}","key":"Invalid Response Code: 400","retryable":false,"what":"std::exception"}
***

1054478 [2021-05-06 17:55:51.946] [main] [info] Identity created at 1620316551 - using ID Schema 1
1054478 [2021-05-06 17:55:51.947] [main] [info] ------------- Starting Sync (myexhangeemail@example.com) ---------------
1054478 [2021-05-06 17:55:51.952] [metadata] [info] Metadata sync disabled, not logged in.
1054478 [2021-05-06 17:55:54.385] [main] [info] Waking all workers...
1054478 [2021-05-06 17:55:54.385] [main] [info] Metadata expiration 0 is further in future than wake time 0
1054478 [2021-05-06 17:55:54.385] [background] [info] Fetching XOAuth2 access token (office365) for 78406ad9
1054478 [2021-05-06 17:55:54.671] [background] [critical] 
***
*** Mailspring Sync 
*** An exception occurred during program execution: 
*** {"debuginfo":"https://login.microsoftonline.com/common/oauth2/v2.0/token RETURNED {\"error\":\"invalid_grant\",\"error_description\":\"AADSTS700081: The refresh token has expired due to maximum lifetime. The token was issued on 2021-05-05T15:10:49.0974195+00:00 and the maximum allowed lifetime for this application is 1.00:00:00.\\r\\nTrace ID: 99e76980-f32c-4100-b5d7-6dff2eaca200\\r\\nCorrelation ID: 2368e1df-35a5-4633-a5a6-ca8d212bcc7d\\r\\nTimestamp: 2021-05-06 15:55:54Z\",\"error_codes\":[700081],\"timestamp\":\"2021-05-06 15:55:54Z\",\"trace_id\":\"99e76980-f32c-4100-b5d7-6dff2eaca200\",\"correlation_id\":\"2368e1df-35a5-4633-a5a6-ca8d212bcc7d\",\"error_uri\":\"https://login.microsoftonline.com/error?code=700081\"}","key":"Invalid Response Code: 400","retryable":false,"what":"std::exception"}
***

If other people could send their logs, than would make tracing the bug easier (make sure you properly redact them :slight_smile: ). Maybe I can help fix it then.

btw: the hostname definitely exists

❯ nslookup login.microsoftonline.com                                                                                                                                                               21:16:09
Server:		127.0.0.53
Address:	127.0.0.53#53
Non-authoritative answer:
login.microsoftonline.com	canonical name = a.privatelink.msidentity.com.
a.privatelink.msidentity.com	canonical name = prda.aadg.msidentity.com.
prda.aadg.msidentity.com	canonical name = www.tm.a.prd.aadg.trafficmanager.net.
Name:	www.tm.a.prd.aadg.trafficmanager.net
Address: 40.126.31.1
Name:	www.tm.a.prd.aadg.trafficmanager.net
Address: 40.126.31.4
Name:	www.tm.a.prd.aadg.trafficmanager.net
Address: 40.126.31.143
Name:	www.tm.a.prd.aadg.trafficmanager.net
Address: 20.190.159.132
Name:	www.tm.a.prd.aadg.trafficmanager.net
Address: 20.190.159.138
Name:	www.tm.a.prd.aadg.trafficmanager.net
Address: 40.126.31.8
Name:	www.tm.a.prd.aadg.trafficmanager.net
Address: 40.126.31.137
Name:	www.tm.a.prd.aadg.trafficmanager.net
Address: 40.126.31.139
www.tm.a.prd.aadg.trafficmanager.net	canonical name = dub2.current.a.prd.aadg.trafficmanager.net.
2 Likes