Skip to content

HTTP 401 when signing in with 2FA #198

@grisumedia

Description

@grisumedia

Debugging steps completed

  • I tried uvx garth login and can reproduce the issue

Describe the issue

Since 2026-03-16 08:00 GMT, I'm not able to login anymore. That's the last time my script ran successfully.
I was running the outdated garth 0.5.7 from Arch Linux AUR on Python 3.14.3, but switching to garth 0.6.3 installed via pip did not solve the problem. Downgrading Python to 3.13.12 doesn't help either.
I have enabled 2FA and cannot disable it, so I unfortunately cannot check if it would work without 2FA.

Steps to reproduce

  1. Run garth login
  2. Login with 2FA
  3. HTTP 401 error appears

Error message

File "/opt/garminbadges/env/bin/garth", line 6, in <module>
    sys.exit(main())
             ~~~~^^
  File "/opt/garminbadges/env/lib/python3.14/site-packages/garth/cli.py", line 30, in main
    garth.login(email, password)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/opt/garminbadges/env/lib/python3.14/site-packages/garth/http.py", line 203, in login
    self.oauth1_token, self.oauth2_token = sso.login(
                                           ~~~~~~~~~^
        *args, **kwargs, client=self
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/garminbadges/env/lib/python3.14/site-packages/garth/sso.py", line 142, in login
    return _complete_login(client)
  File "/opt/garminbadges/env/lib/python3.14/site-packages/garth/sso.py", line 267, in _complete_login
    oauth1 = get_oauth1_token(ticket, client)
  File "/opt/garminbadges/env/lib/python3.14/site-packages/garth/sso.py", line 158, in get_oauth1_token
    resp.raise_for_status()
    ~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/garminbadges/env/lib/python3.14/site-packages/requests/models.py", line 1026, 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-2585026-DLUjRfJp59XLj2fAkSVD-cas&login-url=https://sso.garmin.com/sso/embed&accepts-mfa-tokens=true

Garth version

0.6.3

Python version

3.14.3

Logfire telemetry link (optional)

No response

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