Skip to main content

Self-healing Garmin Connect OAuth authentication — login, token refresh, and rate limit recovery

Project description

garmin-auth

Self-healing Garmin Connect OAuth authentication for Python.

Handles the complex Garmin SSO flow (OAuth1 → OAuth2), automatic token refresh, and rate limit recovery — so you don't have to.

Install

pip install garmin-auth

For PostgreSQL token storage:

pip install garmin-auth[db]

Quick Start

from garmin_auth import GarminAuth

auth = GarminAuth(email="you@example.com", password="yourpassword")
client = auth.login()  # Returns an authenticated garminconnect.Garmin client

# Use the client
activities = client.get_activities(0, 10)

Or use environment variables:

export GARMIN_EMAIL=you@example.com
export GARMIN_PASSWORD=yourpassword
auth = GarminAuth()
client = auth.login()

CLI

# Login and save tokens
garmin-auth login --email you@example.com --password yourpassword

# Check token status
garmin-auth status

# Refresh tokens (for cron jobs / CI)
garmin-auth refresh

Token Storage

File-based (default): Tokens saved to ~/.garminconnect/ as JSON files.

auth = GarminAuth(token_dir="~/.garminconnect")

PostgreSQL: For CI/CD or multi-machine setups.

from garmin_auth import GarminAuth, DBTokenStore

auth = GarminAuth(store=DBTokenStore("postgresql://user:pass@host/db"))

How It Works

Three strategies, tried in order:

  1. Cached token — If OAuth2 has >1h remaining, use it (instant)
  2. Token exchange — Use OAuth1 to get fresh OAuth2 (no password needed)
  3. Full SSO login — Email/password through Garmin's SSO flow (last resort)

This means tokens stay fresh automatically, and even if they fully expire, the package recovers without manual intervention.

Docker

docker build -t garmin-auth .
docker run -e GARMIN_EMAIL=... -e GARMIN_PASSWORD=... garmin-auth refresh

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

garmin_auth-0.1.1.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

garmin_auth-0.1.1-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file garmin_auth-0.1.1.tar.gz.

File metadata

  • Download URL: garmin_auth-0.1.1.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for garmin_auth-0.1.1.tar.gz
Algorithm Hash digest
SHA256 16c5b26709549a098752d8c82e79a55821156e2bd9c97bc7e4a4692120452e47
MD5 19840dbc87d5ef14ec42f7682703a30c
BLAKE2b-256 530f9b26d3ab0ec4e6f53dbacad25d8b8107c5cd352308eaf5a4e3582673123b

See more details on using hashes here.

Provenance

The following attestation bundles were made for garmin_auth-0.1.1.tar.gz:

Publisher: publish.yml on drkostas/garmin-auth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file garmin_auth-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: garmin_auth-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for garmin_auth-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 84aa2911e5ec4dfcfb7e52441e5e23357cf528fbb9757f86eb53dbb7362575d0
MD5 560cbf521d78ac070f5e598b07a7d18b
BLAKE2b-256 9cd18de20093ee83c31b55443caa348f92e44c34bab6d503cfb8e22e82423770

See more details on using hashes here.

Provenance

The following attestation bundles were made for garmin_auth-0.1.1-py3-none-any.whl:

Publisher: publish.yml on drkostas/garmin-auth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page