Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kobo Sync request fails with invalid token #2318

Closed
mvdkleijn opened this issue Feb 16, 2022 · 13 comments
Closed

Kobo Sync request fails with invalid token #2318

mvdkleijn opened this issue Feb 16, 2022 · 13 comments
Labels

Comments

@mvdkleijn
Copy link

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 - e0e0422 - 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
Copy link
Author

@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
Copy link
Author

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

@the-mann
Copy link

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

@mvdkleijn
Copy link
Author

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)

@the-mann
Copy link

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

@mvdkleijn
Copy link
Author

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.

@the-mann
Copy link

the-mann commented Jan 5, 2023

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

@mvdkleijn
Copy link
Author

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
Copy link
Author

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?

@DanWillman
Copy link

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.

@znedw
Copy link

znedw commented May 11, 2023

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.

@peter9teufel
Copy link

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.

@DanielGeoffreyHodgkins
Copy link

Context: I'm running Calibre-web on a raspberry-pi only on my internal network and saw this same issue. Seems like 24 hours after the token is issued successfully, the refresh doesn't work, but downloading books from the server does still work, so it's only annoying if you're using the syncing functionalities for other reasons

For anyone else who stumbles across this issue with the error "Sync Failed. Please Try Again." this fix worked for me! The file was located here if you're using venv: ~/.venv/lib/python3.11/site-packages/calibreweb/cps/kobo.py, but the fix works just the same.

Debug logs showed 401 response trying to refresh the token

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants