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.

5 Likes

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

3 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).

2 Likes

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!

3 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

How long do we need to wait?

If you tell me where to get the log, I am happy to share mine as I have the same problem too

You can access the log directory by selecting Developer > Open Mailsync Logs
image
This should open a directory with several other directories and files. The files called mailsync-*.log* are the ones that are needed.

Alternatively you can also copy the error details from accounts settings page (Edit>Preferences>Accounts)

20210520-1-account.log (3.1 KB) mailsync-9db43d24.log (1.2 MB)

I too, been having this issue for a while, here are the logs.

As a rule, all updates will be posted on the thread. If there are none posted, there are no updates. Your patience is appreciated. Mailspring is built and maintained by volunteers — even the core developer does this in addition to a full time job.

As a rule, asking for updates, status, or timeframe won’t hurry things along. If you want to help get a bug resolved or feature implemented quicker, here’s some things you can do, depending on your available time and skills:

  1. Vote. This raises the priority in planning. Anyone can do this.
  2. Help diagnose. Checking logs, testing out scenarios, or even digging around in the code if you’re up to the challenge all help move towards a resolution.
  3. Coordinate with other reporters. If you see similar bug reports, possible duplicates, or other posts with hints, helping get those individuals involved in diagnostics helps a lot!
  4. Attempting a PR. If you know anything about coding — even a little — you can check out the Mailspring source code from GitHub and try to fix the bug or implement the feature yourself. Even if you aren’t successful, or the fix isn’t ideal, the attempt still helps us!

And, of course, you can help just by being involved in the community: helping answer questions, triage bugs, and discuss features takes pressure off the developers, so they have time to focus on writing awesome code.

Unfortunately my mainspring shows no log there

I think I found the log. This is what I get when mailsprin disconnects:

Mailspring Version: 1.9.1-30ef802f
Platform: darwin
Account State: invalid
Account Provider: office365
IMAP Server: outlook.office365.com
SMTP Server: smtp.office365.com


43415 [2021-05-30 14:45:04.012] [background] [critical] *** Stack trace (line numbers are approximate):
*** in mailsync ValidateRequestResp(CURLcode, void*, string)
*** in mailsync PerformRequest(void*)
*** in mailsync PerformJSONRequest(void*)
*** in mailsync MakeOAuthRefreshRequest(string, string, string)
*** in mailsync XOAuth2TokenManager::partsForAccount(shared_ptr)
*** in mailsync MailUtils::configureSessionForAccount(mailcore::IMAPSession&, shared_ptr)
*** in mailsync SyncWorker::configure()
*** in mailsync runBackgroundSyncWorker()
*** in mailsync main::$_6::operator()() const
*** in mailsync void* __thread_proxy(void*)
*** in mailsync thread_start()


43418 [2021-05-30 14:45:04.209] [main] [info] Identity created at 1621150189 - using ID Schema 1
43418 [2021-05-30 14:45:04.209] [main] [info] ------------- Starting Sync (t.krupnik@cgiar.org) ---------------
43418 [2021-05-30 14:45:04.215] [metadata] [info] Metadata delta stream starting…
43418 [2021-05-30 14:45:05.219] [background] [info] Fetching XOAuth2 access token (office365) for 2bed0da4
43418 [2021-05-30 14:45:07.481] [background] [critical]


*** Mailspring Sync
*** An exception occurred during program execution:
*** {“debuginfo”:"Sign in to your account RETURNED {“error”:“invalid_grant”,“error_description”:“AADSTS700081: The refresh token has expired due to maximum lifetime. The token was issued on 2021-05-29T08:29:13.2388696+00:00 and the maximum allowed lifetime for this application is 1.00:00:00.\r\nTrace ID: d0bf2fb4-9f40-42ed-8e23-f8cfc44df600\r\nCorrelation ID: 8523d530-03a5-4468-8697-1d198371a2b8\r\nTimestamp: 2021-05-30 08:45:06Z”,“error_codes”:[700081],“timestamp”:“2021-05-30 08:45:06Z”,“trace_id”:“d0bf2fb4-9f40-42ed-8e23-f8cfc44df600”,“correlation_id”:“8523d530-03a5-4468-8697-1d198371a2b8”,“error_uri”:“https://login.microsoftonline.com/error?code=700081"}",“key”:"Invalid Response Code: 400”,“retryable”:false,“what”:“std::exception”}


43418 [2021-05-30 14:45:07.481] [background] [critical] *** Stack trace (line numbers are approximate):
*** in mailsync ValidateRequestResp(CURLcode, void*, string)
*** in mailsync PerformRequest(void*)
*** in mailsync PerformJSONRequest(void*)
*** in mailsync MakeOAuthRefreshRequest(string, string, string)
*** in mailsync XOAuth2TokenManager::partsForAccount(shared_ptr)
*** in mailsync MailUtils::configureSessionForAccount(mailcore::IMAPSession&, shared_ptr)
*** in mailsync SyncWorker::configure()
*** in mailsync runBackgroundSyncWorker()
*** in mailsync main::$_6::operator()() const
*** in mailsync void* __thread_proxy(void*)
*** in mailsync thread_start()