Garth
Garth is a Python client for Garmin SSO authentication and the Garmin Connect API. It provided a way to programmatically log in to Garmin Connect and access user data. As of version 0.8.0, Garth is deprecated and no longer maintained due to changes in Garmin's authentication flow, rendering the library effectively unusable for its primary purpose.
Warnings
- breaking Garth is officially deprecated as of v0.8.0 and no longer maintained. Garmin changed its authentication flow, rendering the library's core login functionality unusable.
- deprecated Importing `garth` from v0.8.0 onwards will issue a `DeprecationWarning` to explicitly inform users of its inactive status.
- gotcha Prior to v0.7.9, users frequently encountered 'Client app validation failed' (401) errors due to incorrect client IDs and service URLs (an iOS vs. Android client identity mismatch).
- gotcha Versions 0.7.7 and 0.7.8 had issues with inconsistent browser headers vs. mobile API endpoints, leading to 401 on login. This was temporarily introduced and then reverted.
Install
-
pip install garth
Imports
- garth
import garth
Quickstart
import garth
import os
email = os.environ.get('GARMIN_EMAIL', 'your_email@example.com')
password = os.environ.get('GARMIN_PASSWORD', 'your_password')
print("Attempting to log in with Garth (will likely fail due to library deprecation).")
try:
# This login method is now broken due to Garmin's auth flow changes as of Garth v0.8.0
# It is provided for historical context of intended usage.
garth.login(email, password)
print("Login attempted successfully (unexpected).")
# If login miraculously worked, you could access APIs like this:
# user_profile = garth.client.connectapi('/userprofile-service/userprofile')
# print(f"User Profile: {user_profile}")
except Exception as e:
print(f"An error occurred during Garth login: {e}")
print("This is expected because Garth is deprecated and no longer works with Garmin's current authentication.")
print("Please see Garth's GitHub repository for more details on its deprecation.")