darobin / notion-backup

Simple command to backup a Notion workspace
MIT License
425 stars 63 forks source link

401 Unauthorized using multiple accounts #9

Closed klydra closed 3 years ago

klydra commented 3 years ago

The token seems to expire after < 10min which results in a 401 Unauthorized response from the server.

darobin commented 3 years ago

I can't reproduce that error, my token seems to stay good for ~three months.

klydra commented 3 years ago

I seem to have figured it out. The token_v2 should be a session identifier of some sort, so the three months you're describing make sense, as it should expire at some point. But it turns out that immediately after you log out, all processes using this token are stopped and the token will be invalidated, hence the 401 Unauthorized. Since I use multiple noition accounts, this was also the case when setting up the backup repos for all of them, as I switched between different accounts and as a result of that, invalidating the token every time.

The solution would be, using different dedicated browsers for each account to always have an active session for the token to persist.

darobin commented 3 years ago

Thanks for the investigation — that makes sense. I don't think there's anything I can do about that because Notion haven't yet added the backup endpoint to their official API that can use authentication separate from your own.

There might be a workaround in which you create another account and give them access to your workspace, then never log them out and export using their token. It's a hack, but hacks is what we have at this point!