All checks were successful
Deploy / deploy (push) Successful in 1m36s
The garth library uses Pydantic dataclasses for OAuth tokens which don't have a serialize() method. Use model_dump() instead, and fix expires_at handling since it's an integer timestamp not a datetime object. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
# ABOUTME: PhaseFlow Garmin Token Generator using garth library.
|
|
# ABOUTME: Run this locally to authenticate with Garmin (supports MFA).
|
|
"""
|
|
PhaseFlow Garmin Token Generator
|
|
Run this locally to authenticate with Garmin (supports MFA)
|
|
|
|
Usage:
|
|
pip install garth
|
|
python3 garmin_auth.py
|
|
"""
|
|
import json
|
|
from datetime import datetime
|
|
from getpass import getpass
|
|
|
|
try:
|
|
import garth
|
|
except ImportError:
|
|
print("Error: garth library not installed.")
|
|
print("Please install it with: pip install garth")
|
|
exit(1)
|
|
|
|
email = input("Garmin email: ")
|
|
password = getpass("Garmin password: ")
|
|
|
|
# MFA handled automatically - prompts if needed
|
|
garth.login(email, password)
|
|
|
|
tokens = {
|
|
"oauth1": garth.client.oauth1_token.model_dump(),
|
|
"oauth2": garth.client.oauth2_token.model_dump(),
|
|
"expires_at": garth.client.oauth2_token.expires_at
|
|
}
|
|
|
|
print("\n--- Copy everything below this line ---")
|
|
print(json.dumps(tokens, indent=2))
|
|
print("--- Copy everything above this line ---")
|
|
expires_dt = datetime.fromtimestamp(tokens['expires_at'])
|
|
print(f"\nTokens expire: {expires_dt.isoformat()}")
|