Closed cycomanic closed 3 years ago
I received a similar response when trying to connect to the rM cloud with rmfuse
:
Failed to decode JSON from bytearray(b'Serving request failed, Msg: invalid token: token contains an invalid number of segments: invalid token, Origin: invalid token: token contains an invalid number of segments: invalid token, HTTPCode: 401\n')
Response code: 401
Traceback (most recent call last):
File "/home/lennart/.local/lib/python3.8/site-packages/rmcl/api.py", line 198, in update_items
response_json = response.json()
File "/home/lennart/.local/lib/python3.8/site-packages/asks/response_objects.py", line 104, in json
return _json.loads(body, **kwargs)
File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/lennart/.local/bin/rmfuse", line 8, in <module>
sys.exit(main())
File "/home/lennart/.local/lib/python3.8/site-packages/rmfuse/fuse.py", line 396, in main
trio.run(pyfuse3.main)
File "/home/lennart/.local/lib/python3.8/site-packages/trio/_core/_run.py", line 1932, in run
raise runner.main_task_outcome.error
File "/home/lennart/.local/lib/python3.8/site-packages/_pyfuse3.py", line 30, in wrapper
await fn(*args, **kwargs)
File "src/pyfuse3.pyx", line 773, in main
File "/home/lennart/.local/lib/python3.8/site-packages/trio/_core/_run.py", line 815, in __aexit__
raise combined_error_from_nursery
File "/home/lennart/.local/lib/python3.8/site-packages/_pyfuse3.py", line 30, in wrapper
await fn(*args, **kwargs)
File "src/internal.pxi", line 272, in _session_loop
File "src/handlers.pxi", line 104, in fuse_getattr_async
File "/home/lennart/.local/lib/python3.8/site-packages/rmfuse/fuse.py", line 193, in getattr
item = await self.get_by_id(self.get_id(inode))
File "/home/lennart/.local/lib/python3.8/site-packages/rmfuse/fuse.py", line 138, in get_by_id
return await Item.get_by_id(id_)
File "/home/lennart/.local/lib/python3.8/site-packages/rmcl/items.py", line 46, in get_by_id
return await (await api.get_client()).get_by_id(id_)
File "/home/lennart/.local/lib/python3.8/site-packages/rmcl/api.py", line 229, in get_by_id
await self.update_items()
File "/home/lennart/.local/lib/python3.8/site-packages/rmcl/api.py", line 202, in update_items
raise ApiError("Failed to decode JSON data")
rmcl.exceptions.ApiError: Failed to decode JSON data
Same here, rmfuse version 0.2.1, rmcl version 0.4.0
[nix-shell:~/proj/remarkable]$ rmfuse -v -m orig _remarkable/
DEBUG:llfuse:Initializing llfuse
DEBUG:llfuse:Calling fuse_mount
DEBUG:llfuse:Calling fuse_lowlevel_new
DEBUG:llfuse:Calling fuse_session_add_chan
DEBUG:rmfuse.fuse:Mounting on _remarkable/
DEBUG:llfuse:Calling fuse_session_loop
DEBUG:rmcl.api:Got 401 code; trying to renew token
DEBUG:rmcl.api:Renewing user token
ERROR:rmcl.api:Failed to decode JSON from bytearray(b'Serving request failed, Msg: invalid token: token contains an invalid number of segments: invalid token, Origin: invalid token: token contains an invalid number of segments: invalid token, HTTPCode: 401\n')
ERROR:rmcl.api:Response code: 401
INFO:llfuse:handler raised <class 'rmcl.exceptions.ApiError'> exception (Failed to decode JSON data), terminating main loop.
DEBUG:llfuse:Terminated main loop because request handler raised exception, re-raising..
DEBUG:llfuse:Calling fuse_session_remove_chan
DEBUG:llfuse:Calling fuse_session_destroy
DEBUG:llfuse:Calling fuse_unmount
@grwlf @lckarssen see my pull request #2 on how to fix this.
I confirm that the patch in PR #2 works. :+1:
Thanks for the quick solution @cycomanic!
I see an error when trying to access the cloud API. It seems like the access token does not work properly. See below