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

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()


Similar thing for me with 1.9 snap. My office365 school account disconnects within minutes of setting it up again. Downloads everything fine at first, but then gives that error and does not reconnect.

Odd thing is when I connect the account, it doesn’t go through 2-factor authentication (university uses Duo security). I wonder if that has something to do with it?

Issue seems to start with error messages in the logs of “Local model is not present”

Generally, logs show:

19681 [2021-06-14 11:40:41.832] [main] [info] Identity created at 1548560126 - using ID Schema 1
19681 [2021-06-14 11:40:41.833] [main] [info] ------------- Starting Sync (@.EDU) ---------------
19681 [2021-06-14 11:40:41.837] [metadata] [info] Metadata delta stream starting…
19681 [2021-06-14 11:40:41.838] [background] [info] Fetching XOAuth2 access token (office365) for d7b5e870
19681 [2021-06-14 11:40:42.341] [background] [info] Saving updated XOAuth2 refresh token (office365) for d7b5e870
19681 [2021-06-14 11:40:42.342] [background] [info] Marking all folders as busy
19681 [2021-06-14 11:40:42.342] [background] [info] Syncing folder list…
19681 [2021-06-14 11:40:42.394] [metadata] [info] Received metadata V1 for (message - TCzx9aPH8zEDgrpYvyMcJZrF4uDKLbshAfZNwA9Qz)
19681 [2021-06-14 11:40:42.394] [metadata] [info] – Local model is not present. Saving to waiting table.
19681 [2021-06-14 11:40:42.395] [metadata] [info] Received metadata V3 for (message - TCzx9aPH8zEDgrpYvyMcJZrF4uDKLbshAfZNwA9Qz)

and then eventually gives:

*** Mailspring Sync
*** An exception occurred during program execution:
*** {“debuginfo”:“syncFoldersAndLabels - fetchAllFolders”,“key”:“ErrorConnection”,“retryable”:true,“what”:“std::exception”}

I believe this has to do with a change earlier this year by Microsoft on how token lifetimes can be configured, which would explain why it’s behaving differently per organization.

Configurable token lifetimes

1 Like

I believe the reason for the token lifetime to only be 24 hours is that the Mailspring application is registered as a Single Page Application at Microsoft. Look at this post under the other thread:

1 Like

Could mailspring refresh this token before it expires? This is such a nice email client, but this bug is infuriating.

2 Likes

Same here. Please fix this! I have been using Thunderbird until this issue is resolved, I love mailspring and want to come back to it!

Any update on this? Its been a year since this issue was first opened and it still hasn’t been resolved. I’m surprised this wasn’t a higher priority given that many people use office365/exchange accounts, especially for schools. I really want to use mailspring again as my email client.

If there is anything further that maybe I could provide I can try my best too.

Yes, its a beautiful client— but in the end office365 mail does not work with it.
Although— everytime I click “Sync Now” it seems to reconnect. But definitely not a reliable solution

Hey guys!
I was able to get around this issue by adding my account using IMAP/SMTP.
When adding your account, instead of selecting Office 365, select IMAP/SMTP at the bottom.

Then set your incoming and outgoing mail server details as below:
Incoming Mail (IMAP):
Server name: outlook.office365.com
Port: 993
Encryption method: TLS

Outgoing Mail (SMTP):
Server name: smtp.office365.com
Port: 587
Encryption method: STARTTLS

Before I had to manually reconnect every morning after starting my PC, but after this configuration, it never got disconnected and it’s been a few days now.

This will only work for users that are within a tenant that specifically allows this.

I really liked this application; however, this issue is very bored.

I am using GNU/Linux Debian Stable on three machines (two laptops and one desktop), and I’ve added the Office 365 business account because of my work. This work very well, but I have the “Cannot authenticate with "account” message all the time.

Checking the log file:

29345 [2022-08-05 20:16:31.445] [main] [info] Identity created at 1659741391 - using ID Schema 1
29345 [2022-08-05 20:16:31.445] [main] [info] ------------- Starting Sync (e-mail@office365) ---------------
29345 [2022-08-05 20:16:31.447] [metadata] [info] Metadata sync disabled, not logged in.
29345 [2022-08-05 20:16:31.447] [background] [info] Fetching XOAuth2 access token (office365) for c9b2ead6
29345 [2022-08-05 20:16:32.064] [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\":\"AADSTS700084: The refresh token was issued to a single page app (SPA), and therefore has a fixed, limited lifetime of 1.00:00:00, which cannot be extended. It is now expired and a new sign in request must be sent by the SPA to the sign in page. The token was issued on 2022-07-27T22:59:45.1791085Z.\\r\\nTrace ID: removed\\r\\nCorrelation ID: 3850f8c9-6293-48f4-a651-6e378b5fde9d\\r\\nTimestamp: 2022-08-05 23:16:31Z\",\"error_codes\":[700084],\"timestamp\":\"2022-08-05 23:16:31Z\",\"trace_id\":\"**removed***\",\"correlation_id\":\"**removed***\",\"error_uri\":\"https://login.microsoftonline.com/error?code=700084\"}","key":"Invalid Response Code: 400","retryable":false,"what":"std::exception"}
***

Version: 1.10.3-a476c230

Do you have some date to resolve it?

Thank you.

Hello.

Just for update: I update version 1.10.5-1ce06f18, and I don’t see this error more. Is anyone else?

However, I see some drops in performance in this version.

I’m using the same version but I’m still getting the same error.

Mailspring Version: 1.10.5-1ce06f18
Platform: win32
Account State: invalid
Account Provider: outlook
IMAP Server: imap-mail.outlook.com
SMTP Server: smtp-mail.outlook.com
--------------------------------------------
12700 [2022-08-17 17:52:45.347] [metadata] [info] Will retry in 3 sec.
12700 [2022-08-17 17:52:45.676] [background] [info] Marking all folders as `busy`
12700 [2022-08-17 17:52:45.678] [background] [info] Syncing folder list...
12700 [2022-08-17 17:52:46.698] [background] [critical] 
***
*** Mailspring Sync 
*** An exception occurred during program execution: 
*** {"debuginfo":"syncFoldersAndLabels - fetchAllFolders","key":"ErrorAuthentication","retryable":false,"what":"Unknown exception"}
***

12700 [2022-08-17 17:52:46.698] [background] [critical] *** Stack trace (line numbers are approximate):
*** 519  SyncWorker::syncFoldersAndLabels()
*** 180  runBackgroundSyncWorker()
*** 692  ::operator()
*** 210  _Pad::_Call_func()
***

10320 [2022-08-17 17:52:48.044] [main] [info] Identity created at 1569192889 - using ID Schema 1
10320 [2022-08-17 17:52:48.045] [main] [info] ------------- Starting Sync (XXXXXXX@hotmail.com) ---------------
10320 [2022-08-17 17:52:48.049] [metadata] [info] Metadata delta stream starting...
10320 [2022-08-17 17:52:48.591] [metadata] [info] Metadata delta stream closed.
10320 [2022-08-17 17:52:48.707] [metadata] [info] Will retry in 3 sec.
10320 [2022-08-17 17:52:49.056] [background] [info] Marking all folders as `busy`
10320 [2022-08-17 17:52:49.059] [background] [info] Syncing folder list...
10320 [2022-08-17 17:52:50.527] [background] [critical] 
***
*** Mailspring Sync 
*** An exception occurred during program execution: 
*** {"debuginfo":"syncFoldersAndLabels - fetchAllFolders","key":"ErrorAuthentication","retryable":false,"what":"Unknown exception"}
***

10320 [2022-08-17 17:52:50.527] [background] [critical] *** Stack trace (line numbers are approximate):
*** 519  SyncWorker::syncFoldersAndLabels()
*** 180  runBackgroundSyncWorker()
*** 692  ::operator()
*** 210  _Pad::_Call_func()
***

10396 [2022-08-17 17:52:52.167] [main] [info] Identity created at 1569192889 - using ID Schema 1
10396 [2022-08-17 17:52:52.168] [main] [info] ------------- Starting Sync (XXXXXX@hotmail.com) ---------------
10396 [2022-08-17 17:52:52.180] [metadata] [info] Metadata delta stream starting...
10396 [2022-08-17 17:52:52.809] [metadata] [info] Metadata delta stream closed.
10396 [2022-08-17 17:52:52.941] [metadata] [info] Will retry in 3 sec.
10396 [2022-08-17 17:52:53.182] [background] [info] Marking all folders as `busy`
10396 [2022-08-17 17:52:53.183] [background] [info] Syncing folder list...
10396 [2022-08-17 17:52:54.830] [background] [critical] 
***
*** Mailspring Sync 
*** An exception occurred during program execution: 
*** {"debuginfo":"syncFoldersAndLabels - fetchAllFolders","key":"ErrorAuthentication","retryable":false,"what":"Unknown exception"}
***

10396 [2022-08-17 17:52:54.830] [background] [critical] *** Stack trace (line numbers are approximate):
*** 519  SyncWorker::syncFoldersAndLabels()
*** 180  runBackgroundSyncWorker()
*** 692  ::operator()
*** 210  _Pad::_Call_func()
***

OS and Version: Windows 10 Pro
Installation Method: Installer
Mailspring Version: 1.10.5-1ce06f18

Hi everyone.

An update on that issue?

Thank you.

It’s not only with office 365, it also happens with gmail, check this issue for more information and error logs and more

It happens daily now, It’s getting really annoying.