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

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.