Fix garmin token expires_at format for PocketBase compatibility
Output expires_at as ISO 8601 date string instead of Unix timestamp. PocketBase date fields expect ISO format, and the integer was causing token saves to fail silently. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -44,14 +44,14 @@ except Exception as e:
|
|||||||
oauth1_adapter = TypeAdapter(OAuth1Token)
|
oauth1_adapter = TypeAdapter(OAuth1Token)
|
||||||
oauth2_adapter = TypeAdapter(OAuth2Token)
|
oauth2_adapter = TypeAdapter(OAuth2Token)
|
||||||
|
|
||||||
|
expires_at_ts = garth.client.oauth2_token.expires_at
|
||||||
tokens = {
|
tokens = {
|
||||||
"oauth1": oauth1_adapter.dump_python(garth.client.oauth1_token, mode='json'),
|
"oauth1": oauth1_adapter.dump_python(garth.client.oauth1_token, mode='json'),
|
||||||
"oauth2": oauth2_adapter.dump_python(garth.client.oauth2_token, mode='json'),
|
"oauth2": oauth2_adapter.dump_python(garth.client.oauth2_token, mode='json'),
|
||||||
"expires_at": garth.client.oauth2_token.expires_at
|
"expires_at": datetime.fromtimestamp(expires_at_ts).isoformat()
|
||||||
}
|
}
|
||||||
|
|
||||||
print("\n--- Copy everything below this line ---")
|
print("\n--- Copy everything below this line ---")
|
||||||
print(json.dumps(tokens, indent=2))
|
print(json.dumps(tokens, indent=2))
|
||||||
print("--- Copy everything above this line ---")
|
print("--- Copy everything above this line ---")
|
||||||
expires_dt = datetime.fromtimestamp(tokens['expires_at'])
|
print(f"\nTokens expire: {tokens['expires_at']}")
|
||||||
print(f"\nTokens expire: {expires_dt.isoformat()}")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user