Skip to content

The script stopped working; now I'm getting 403 and 401 and 429 errors #233

@msgrt

Description

@msgrt

A few days ago, I manually installed the script on a Raspberry Pi 5 (Bookworm). Everything worked as described. I entered my email, password, and MFA code when I first ran it. After the data from the last 7 days was automatically imported, I fetched the data from the last 5 years. Everything went smoothly.

Two days later, no new data suddenly started appearing in the dashboard. According to the log, this was due to a 403 error.
First, I tried a fresh setup, which was again stopped by a 403 error.
So I deleted the image and ran the setup again. Since then, all attempts have resulted in the same 401 error.

Here’s what else I’ve tried since then:

  • Disabled MFA on my Garmin account
  • Connected via mobile hotspot
  • Connected via VPN
  • Waited 2 days between attempts, in case Garmin had temporarily locked the account

I can access my Garmin account from the network where the Raspberry Pi is located without any issues, both from my smartphone and from my PC. So the IP shouldn’t be blocked.

I’m running out of ideas and would appreciate any help.

Here’s the error message:
`2026-03-21 17:19:39,467 - INFO - Trying to login to Garmin Connect using token data from directory '~/.garminconnect'...
2026-03-21 17:19:39,468 - WARNING - Session is expired or login information not present/incorrect. You'll need to log in again...login with your Garmin Connect credentials to generate them.
Enter Garminconnect Login e-mail: xyz@domain.com
Enter Garminconnect password (characters will be visible): password
MFA one-time code (via email or SMS): 123456
2026-03-21 17:20:12,514 - ERROR - 401 Client Error: Unauthorized for url: https://connectapi.garmin.com/oauth-service/oauth/preauthorized?ticket=ST-1231101-JhnG7Kw8dlHdNVvqvk2m-cas&login-url=https://sso.garmin.com/sso/embed&accepts-mfa-tokens=true
Traceback (most recent call last):
File "/app/garmin_grafana/garmin_fetch.py", line 139, in garmin_login
garmin.login(TOKEN_DIR)
~~~~~~~~~~~~^^^^^^^^^^^
File "/app/.venv/lib/python3.13/site-packages/garminconnect/init.py", line 408, in login
self.garth.load(normalized_path)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.13/site-packages/garth/http.py", line 231, in load
with open(os.path.join(dir_path, "oauth1_token.json")) as f:
~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/appuser/.garminconnect/oauth1_token.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/app/garmin_grafana/garmin_fetch.py", line 153, in garmin_login
garmin.resume_login(result2, mfa_code)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.13/site-packages/garminconnect/init.py", line 542, in resume_login
result1, result2 = self.garth.resume_login(client_state, mfa_code)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.13/site-packages/garth/http.py", line 173, in resume_login
self.oauth1_token, self.oauth2_token = sso.resume_login(
~~~~~~~~~~~~~~~~^
*args, **kwargs
^^^^^^^^^^^^^^^
)
^
File "/app/.venv/lib/python3.13/site-packages/garth/sso.py", line 240, in resume_login
return _complete_login(client)
File "/app/.venv/lib/python3.13/site-packages/garth/sso.py", line 260, in _complete_login
oauth1 = get_oauth1_token(ticket, client)
File "/app/.venv/lib/python3.13/site-packages/garth/sso.py", line 151, in get_oauth1_token
resp.raise_for_status()
~~~~~~~~~~~~~~~~~~~~~^^
File "/app/.venv/lib/python3.13/site-packages/requests/models.py", line 1024, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://connectapi.garmin.com/oauth-service/oauth/preauthorized?ticket=ST-1231101-JhnG7Kw8dlHdNVvqvk2m-cas&login-url=https://sso.garmin.com/sso/embed&accepts-mfa-tokens=true

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/app/garmin_grafana/garmin_fetch.py", line 1545, in
garmin_obj = garmin_login()
File "/app/garmin_grafana/garmin_fetch.py", line 169, in garmin_login
raise Exception("Session is expired : please login again and restart the script")
Exception: Session is expired : please login again and restart the script`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions