Download and parse data from Garmin Connect or a Garmin watch, FitBit CSV, and MS Health CSV files into and analyze data in Sqlite serverless databases with Jupyter notebooks.
GNU General Public License v2.0
1.18k
stars
142
forks
source link
JSONDecodeError when running garmindb_cli.py: requests.exceptions.JSONDecodeError: Expecting value #245
Describe the bug
I'm encountering a JSONDecodeError when trying to download data using garmindb_cli.py. The script fails during the JSON parsing of a response from the server.
To Reproduce
Steps to reproduce the behavior:
Run the command:
garmindb_cli.py --all --download
Observe the error output.
Expected behavior
I expected the script to successfully download all data without errors.
Logs
Please find below the output and traceback:
___Downloading All Data___
Traceback (most recent call last):
File "/opt/homebrew/lib/python3.11/site-packages/requests/models.py", line 974, in json
return complexjson.loads(self.text, **kwargs)
File "/opt/homebrew/Cellar/python@3.11/3.11.5/lib/python3.11/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/opt/homebrew/Cellar/python@3.11/3.11.5/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/opt/homebrew/Cellar/python@3.11/3.11.5/lib/python3.11/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 "/opt/homebrew/bin/garmindb_cli.py", line 368, in <module>
main(sys.argv[1:])
File "/opt/homebrew/bin/garmindb_cli.py", line 349, in main
download_data(args.overwrite, args.latest, args.stats)
File "/opt/homebrew/bin/garmindb_cli.py", line 113, in download_data
if not download.login():
^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/garmindb/download.py", line 92, in login
self.garth.username
File "/opt/homebrew/lib/python3.11/site-packages/garth/http.py", line 109, in username
return self.profile["userName"]
^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/garth/http.py", line 101, in profile
self._profile = self.connectapi(
^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/garth/http.py", line 171, in connectapi
resp = self.request(method, "connectapi", path, api=True, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/garth/http.py", line 129, in request
self.refresh_oauth2()
File "/opt/homebrew/lib/python3.11/site-packages/garth/http.py", line 168, in refresh_oauth2
self.oauth2_token = sso.exchange(self.oauth1_token, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/garth/sso.py", line 146, in exchange
).json()
^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/requests/models.py", line 978, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Additional context
Operating System: macOS (MacBook Air)
Python Version: 3.11.5 (installed via Homebrew)
Installation Method: Installed via Homebrew
Internet Connection: Stable and verified
Garmin Account: Credentials are correct; able to log in via the web interface
What I've Tried
Updated the garth library using pip install --upgrade garth
Ensured that garmindb_cli.py is up to date
Verified Garmin account credentials
Checked for any API changes or updates in the garth repository
Inspected the response manually to see if an HTML error page is returned instead of JSON
Searched for similar issues but didn't find a solution
Possible Cause
It seems the script is expecting a JSON response but is receiving an unexpected response from the server, possibly due to:
Changes in Garmin's API endpoints or authentication methods
An authentication failure that returns an HTML error page instead of JSON
A need to update the script to handle non-JSON responses gracefully
Bug Report
Describe the bug
I'm encountering a
JSONDecodeError
when trying to download data usinggarmindb_cli.py
. The script fails during the JSON parsing of a response from the server.To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expected the script to successfully download all data without errors.
Logs
Please find below the output and traceback:
Additional context
What I've Tried
pip install --upgrade garth
Possible Cause
It seems the script is expecting a JSON response but is receiving an unexpected response from the server, possibly due to: