Fixed - Issue with the python upload script garminbadges-updater.py

UPDATE: Garth is fixed, it can be upgraded by: pip install garth --upgrade

The python upload script garminbadges-updater.py found here is currently not working. Garmin changed something on their side which breaks Garth (the python package that handles communication with Garmin Connect).

The issue is being discussed here: https://github.com/matin/garth/issues/73

Until it is fixed in Garth, released and the user updates the package there is a fix that works.

Locate the garth package on your computer. On my Windows machine it is found at this path:
C:\Users\[my user]\AppData\Roaming\Python\Python312\site-packages\garth

Open the file http.py in a text editor.

Locate this code:

USER_AGENT = {
    "User-Agent": (
        "Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) "
        "AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
    ),
}

And change it to:

USER_AGENT = {
    "User-Agent": ("GCM-iOS-5.7.2.1"),
}

Save the file and everything should work again.



Garmin Badge Database
Garmin Connect
Change country setting


Comments

  1. Garth may be installed to `c:\Program Files\Python312\Lib\site-packages\garth\`

    ReplyDelete
  2. Found it there on Mac OS : /opt/homebrew/lib/python3.10/site-packages/garth/http.py

    ReplyDelete
  3. Garth is fixed, it can be upgraded by: pip install garth --upgrade

    ReplyDelete
  4. Added a feature to be able to pass a username and sync for that user (this way I can have a cron that updates not only my but also my sons' account). Not the best way to send it, but it's small so maybe it'll be OK this way:
    ------------------------------- 8< -----------------------------------------------
    43a44
    > userName = ""
    95a97,98
    > if userName != '':
    > configDir += f"{userName}/"
    101c104
    < global debugMode
    ---
    > global debugMode, userName
    110a114,116
    > if "-u" in sys.argv:
    > userName = sys.argv[sys.argv.index("-u") + 1]
    > #print(f"userName: {userName}")
    120c126
    < garth.resume("~/.garth")
    ---
    > garth.resume(f"~/.garth/{userName}")
    137c143
    < garth.save("~/.garth")
    ---
    > garth.save(f"~/.garth/{userName}")

    ReplyDelete
    Replies
    1. BTW since it's open source anyway, maybe you could upload it to github

      Delete

Post a Comment

Popular posts from this blog

January 2025 - Challenges and Badges

Dance Fitness has arrived

June 2024 - Challenges and Badges