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.

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