calibre-web icon indicating copy to clipboard operation
calibre-web copied to clipboard

Kobo Sync request fails with invalid token

Open mvdkleijn opened this issue 2 years ago • 13 comments

Describe the bug/problem Installed as a Docker container running on port 80 (inside and out) Enabled Kobo sync Logs show the following:

[2022-02-16 21:22:43,331] DEBUG {cps.ub:80} Found stored session: *********f5dd6be8ae7878062
[2022-02-16 21:22:43,331]  INFO {cps.kobo:1067} Init
[2022-02-16 21:22:43,519] DEBUG {cps.kobo:102} Content: b'{"ResponseStatus":{"ErrorCode":"ExpiredToken","Message":"Expired token"}}'
[2022-02-16 21:22:43,521] DEBUG {cps.kobo:103} StatusCode: 401
[2022-02-16 21:22:43,522] DEBUG {cps.kobo:1082} Kobo: Received unproxied request, changed request port to external server port
[2022-02-16 21:22:43,522] DEBUG {cps.kobo:1092} Kobo: Received unproxied request, changed request url to http://*********:80
[2022-02-16 21:22:43,578] DEBUG {cps.kobo:988} Unimplemented User Request received: http://*********/kobo/*********/v1/user/profile
[2022-02-16 21:22:44,191] DEBUG {cps.kobo:102} Content: b'{"ResponseStatus":{"ErrorCode":"ArgumentException","Message":"Invalid Token Type."}}'
[2022-02-16 21:22:44,193] DEBUG {cps.kobo:103} StatusCode: 400

No clue why it shows invalid token type or expiredtoken... I deleted and regenerated the sync token and updated the kobo device but to no avail.

To Reproduce Steps to reproduce the behavior:

  1. Install Calibre-web
  2. Enable Kobo sync
  3. Adjust url in Kobo device
  4. Manually sync
  5. Sync fails with above error in logs

Expected behavior Sync works

Environment (please complete the following information):

  • OS: Ubuntu arm 64-bit
  • Python version: 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
  • Calibre-Web version: 0.6.16 - e0e04220109920575179a8f924543449c6de0706 - 2022-01-24T19:18:40+01:00
  • Docker container: lscr.io/linuxserver/calibre-web:arm64v8-latest
  • Special Hardware: Pi4 4GB
  • Browser: FF & Kobo Aura H2O Edition 2

Additional context No reverse proxy, everything connected on port 80. Manual check of sync url works and shows bunch of correct looking json. Manual check of download url in json response also works fine.

mvdkleijn avatar Feb 16 '22 20:02 mvdkleijn

@OzzieIsaacs Yes it is using Docker, but I highly doubt the Docker setup is the issue here. Might you have any idea what is causing the error message / how to fix it?

mvdkleijn avatar Apr 23 '22 15:04 mvdkleijn

Still happening with the latest version... anyone have any ideas or suggestions?

mvdkleijn avatar Sep 11 '22 11:09 mvdkleijn

Any update on this? I'm having the exact same issue

the-mann avatar Dec 28 '22 06:12 the-mann

Any update on this? I'm having the exact same issue

Question: are you using a valid Kobo/Rakuten/Partner account or are you using it without an account or a dummy account? (so you can use the device without an account)

mvdkleijn avatar Dec 30 '22 11:12 mvdkleijn

I actually figured it out. Essentially it was because I was using nginx, a reverse proxy, but the settings were misconfigured.

the-mann avatar Dec 30 '22 19:12 the-mann

Ah cool.. For others reading this thread, I figured out my particular case as well:

I manually edited the SQLite database on the Kobo so I could use the device without an account. ('cause I don't like the idea of an account just to use the device)

For basically all intents and purposes, this works fine.... except for the sync with Calibre-web. (see my earlier token issues)

By removing the fake "account" entry and using a real-life account, it works fine.

mvdkleijn avatar Jan 02 '23 15:01 mvdkleijn

@mvdkleijn then we're good to close the issue? 😄

the-mann avatar Jan 05 '23 16:01 the-mann

I guess so... though it's weird to me that what's supposed to be a local solution is apparently depending on the remote server

mvdkleijn avatar Jan 05 '23 16:01 mvdkleijn

Maybe @OzzieIsaacs could comment on the apparent non-local behaviour? Is it expected and normal behaviour for CalibreWeb to require an online Kobo account for the Kobo to be ably to sync successfully?

mvdkleijn avatar Jan 12 '23 08:01 mvdkleijn

I actually figured it out. Essentially it was because I was using nginx, a reverse proxy, but the settings were misconfigured.

@the-mann could you elaborate on which settings you had to update? I'm running into the same issue behind nginx/proxy-man and nothing I've changed has been working for me.

DanWillman avatar Jan 22 '23 20:01 DanWillman

I actually figured it out. Essentially it was because I was using nginx, a reverse proxy, but the settings were misconfigured.

@the-mann could you elaborate on which settings you had to update? I'm running into the same issue behind nginx/proxy-man and nothing I've changed has been working for me.

Not sure if you've tried this but I managed to resolve this issue by setting api_endpoint back to https://storeapi.kobo.com, performing a sync to fetch a new/valid token and then changing api_endpoint. I am behind HAproxy via ssl but I don't think that's the issue.

znedw avatar May 11 '23 01:05 znedw

I actually figured it out. Essentially it was because I was using nginx, a reverse proxy, but the settings were misconfigured.

@the-mann could you elaborate on which settings you had to update? I'm running into the same issue behind nginx/proxy-man and nothing I've changed has been working for me.

Not sure if you've tried this but I managed to resolve this issue by setting api_endpoint back to https://storeapi.kobo.com, performing a sync to fetch a new/valid token and then changing api_endpoint. I am behind HAproxy via ssl but I don't think that's the issue.

Got the same issue, calibre-web installed via pip as recommended in the docs, serving on default port 8083 in my local network, no access from outside my local network needed or setup for sync.

Synching to calibre-web works fine for a day or two, then this error re-appears which can only be fixed by using the original api_endpoint https://storeapi.kobo.com once for a sync, which refreshes the access token for the kobo store.

peter9teufel avatar Jan 09 '24 04:01 peter9teufel