bsdz / google-drive-remarkable-sync

Apps Script library for synchronising Google Drive folder with Remarkable reader.
MIT License
119 stars 17 forks source link

deleted device #7

Closed zelomel closed 3 years ago

zelomel commented 3 years ago

Hi,

I was using your script and everything was fine. I cleaned devices in my.remarkable.com and surely erased the device corresponding to the google-drive script. I tried to configure a new device for the script, then obtained a new one-time code but I obtained an error message: "deleted device".

Here the log:

[20-11-20 19:33:42:391 CET] Using existing Remarkable device id.. [20-11-20 19:33:42:394 CET] Using existing Remarkable device token.. [20-11-20 19:33:42:549 CET] Exception: Échec de la requête pour https://my.remarkable.com. Code renvoyé : 401. Réponse tronquée du serveur : deleted device (Utilisez l'option muteHttpExceptions pour examiner la réponse entière.) at _getUserToken(Remarkable:60:32) at RemarkableAPI(Remarkable:27:39) at Synchronizer(Synchronizer:99:25) at syncGoogleDriveWithRemarkableCloud(Library:11:14)

bsdz commented 3 years ago

I think I know what is happening. I hadn't envisaged deleting devices when I wrote the library and the device ID is cached within your AppScripts local UserProperties service.

Perhaps the following function might help if you run it from your AppScript console. A caveat is I wrote this on my phone and haven't tested it all so probably needs double checking.

function deleteDeviceCache() {
    let userProps = PropertiesService.getUserProperties();
    userProps.deleteProperty(rDeviceTokenKey);
    userProps.deleteProperty(rDeviceIdKey);
}

I hope that helps.

zelomel commented 3 years ago

Unfortunately, that doesn't work. I may have misused the function. Here is the log:


[20-11-22 18:37:44:799 CET] ReferenceError: rDeviceTokenKey is not defined
    at deleteDeviceCache(Code:11:30)
bsdz commented 3 years ago

Try adding these lines either inside or outside that function:

const rDeviceTokenKey = "__REMARKABLE_DEVICE_TOKEN__";

const rDeviceIdKey = "__REMARKABLE_DEVICE_ID__";
zelomel commented 3 years ago

with these constants, the delete function works. No more error message.

However, the sync function still does not work. Same error.

bsdz commented 3 years ago

That's a shame. Not sure what to suggest. Perhaps you could try deleting your Apps Script and starting from afresh?

zelomel commented 3 years ago

I started over with my usual google account. It did not work. I don't know where the ID is cached but it's weird. So I tried with an other google account. It works ! So, my "reMarkable" folder is shared between the 2 google accounts.

Thank you for your help.

Laurent

bsdz commented 3 years ago

I'm glad you have it sorted. I'll add some more information to the readme on the next iteration. I'll close this issue for now.