Joplin Windows v1.0.235 does not sync to OneDrive anymore

Hello,

I have upgraded Joplin to v1.0.235 in one PC running Win10. Sync to OneDrive works perfectly.
Then I upgraded Joplin to v1.0.235 in another PC running Win10. Sync to OneDrive fails with:
Last error: Error: Could not retrieve account details (drive ID, Account type): 401: Unauthorized: { “error”: { “code”: “InvalidAuthenticationToken”, “message”: “CompactToken validation failed with reason code: 80049228.”, “innerError”: { “date”: “2020-08-26T15:36:19”, “request-id”: “a7f8969f-8723-4557-a1fa-b88a9fbc761b” } } }

A check into C:\Users<user>.config\joplin-desktop\log.txt reveals:
2020-08-26 17:24:24: “Could not acquire synchroniser:”
2020-08-26 17:24:24: “Error: Could not retrieve account details (drive ID, Account type): 401: Unauthorized: {
“error”: {
“code”: “InvalidAuthenticationToken”,
“message”: “CompactToken validation failed with reason code: 80049228.”,
“innerError”: {
“date”: “2020-08-26T15:24:26”,
“request-id”: “8162aa33-9f8e-4952-990e-cfbf437088d7”
}
}
}
Error: Could not retrieve account details (drive ID, Account type): 401: Unauthorized: {
“error”: {
“code”: “InvalidAuthenticationToken”,
“message”: “CompactToken validation failed with reason code: 80049228.”,
“innerError”: {
“date”: “2020-08-26T15:24:26”,
“request-id”: “8162aa33-9f8e-4952-990e-cfbf437088d7”
}
}
}
at OneDriveApi.execAccountPropertiesRequest (C:\Program Files\Joplin\resources\app.asar\lib\onedrive-api.js:339:10)
at async SyncTargetOneDrive.initFileApi (C:\Program Files\Joplin\resources\app.asar\lib\SyncTargetOneDrive.js:89:24)
at async SyncTargetOneDrive.fileApi (C:\Program Files\Joplin\resources\app.asar\lib\BaseSyncTarget.js:69:19)
at async SyncTargetOneDrive.initSynchronizer (C:\Program Files\Joplin\resources\app.asar\lib\SyncTargetOneDrive.js:104:39)
at async SyncTargetOneDrive.synchronizer (C:\Program Files\Joplin\resources\app.asar\lib\BaseSyncTarget.js:105:26)”

Apparently Joplin cannot login into OneDrive.

Any hints ?

1 Like

I’m experiencing a comparable error, also with the code 80049228 when attempting to sync via OneDrive (from Mac).

We’ve changed OneDrive handling a bit in this release but it should normally normally only affect OneDrive Business. I’ll look up this error code and see if there’s a fix for it.

I have fixed this and made a Pull Request. The Bug happened because of missing error handling when requesting the account properties. Sorry for that :frowning: and thanks @magr40 for reporting the bug

2 Likes

Thank you @johnny for fixing the bug.

Pardon my ignorance, but where do I find the corrected version?

The corrected version is not released yet. Only Laurent can make new Releases and it seems he didn’t find the time yet to do so.

I recommend you to wait but when you want to fix the problem by your own you can do it by manually updating the value of sync3.context in the table settings of the joplin database which is named database.sqlite and is stored in the config directory (should be ~/.config/joplin-desktop or c:\Users\YOUR_NAME\.config\joplin-desktop ). For this you can use for example the SQLiteBrowser. At the moment the value of sync3.context will be similar to:

{"delta":{"nextLink":"https://graph.microsoft.com/v1.0/drive/root:/Apps/Joplin:/delta?select=name%2cfile%2cfolder%2cfileSystemInfo%2cparentReference%2cdeleted&token=aTE09NjM3MzQxOTgwNDM5MDM7SUQ9REM0NTcxMDNCRkY4Q0NCNiExOTAxO0xSPTYzNzM0MTk4MDQ0NjMwO0VQPTIwO1NJPTYzO0RMRVA9MDtTRz0xO1NPPTI7UEk9Mw"}}

But the JSON text must also include accountType and driveId. The value of accountType must be personal in your case. You can find out your driveId by either checking the SQLite Database on the Windows machine where Joplin still sync to OneDrive or with the help of the Microsoft Graph Explorer. In case of the Microsoft Graph Explorer, you need to login with you account and select on the left panel the option “OneDrive” and the option “Get all the items in my drive”. You then find the driveID in the response preview
Selection_002

With the drive ID and your previous value of ‘sync3.context’ you can correct the value in the db with the following SQL query (you need to enter your values. Make sure that Joplin is not running while executing the SQL query):

UPDATE settings SET value = '{"delta":{"nextLink":"https://graph.microsoft.com/v1.0/drive/root:/Apps/Joplin:/delta?select=name%2cfile%2cfolder%2cfileSystemInfo%2cparentReference%2cdeleted&token=aTE09NjM3MzQxOTgwNDM5MDM7SUQ9REM0NTcxMDNCRkY4Q0NCNiExOTAxO0xSPTYzNzM0MTk4MDQ0NjMwO0VQPTIwO1NJPTYzO0RMRVA9MDtTRz0xO1NPPTI7UEk9Mw"},"accountProperties":{"accountType":"personal","driveId":"dc457103bff8ccb6"}}' WHERE key = 'sync.3.context'

Make sure to write the changes to the db after executing the SQL query. After the values have been corrected in the DB you should be able so sync to OneDrive again. But as said above, it is obviously much easier to wait for the next release.

I’ve released the update with OneDrive fix now, please give it a try and let us know if it works for you:

Thank you @johnny for your reply.

I rather wait for the new release.

There is now a new release. See previous comment from Laurent.

Did anyone test this new release and could confirm if it’s working?

Yes, it is working as expected.