Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Manual credential refresh script for SSH debugging on HuggingFace Spaces. | |
| This script can be run via Dev Mode SSH to manually refresh Google Calendar credentials. | |
| Usage via SSH: | |
| ssh -i ~/.ssh/id_ed25519 pgits-voicecal-ai@ssh.hf.space | |
| cd /app && python refresh_credentials.py | |
| """ | |
| import sys | |
| import os | |
| sys.path.insert(0, '/app') | |
| from app.calendar.auth import CalendarAuth | |
| from app.config import settings | |
| def main(): | |
| print("π§ Manual Google Calendar Credential Refresh Tool") | |
| print("=" * 60) | |
| try: | |
| # Initialize calendar auth | |
| print("π Initializing CalendarAuth...") | |
| auth = CalendarAuth() | |
| # Check current credentials | |
| print("π Checking current credentials...") | |
| credentials = auth.load_credentials() | |
| if not credentials: | |
| print("β No credentials found. Please authenticate via OAuth first.") | |
| return | |
| print(f"π Current expiry: {credentials.expiry}") | |
| print(f"π Token expired: {credentials.expired}") | |
| if credentials.expired: | |
| if credentials.refresh_token: | |
| print("π Refreshing expired credentials...") | |
| from google.auth.transport.requests import Request | |
| credentials.refresh(Request()) | |
| auth.save_credentials(credentials) | |
| print("β Credentials refreshed successfully!") | |
| print(f"π New expiry: {credentials.expiry}") | |
| else: | |
| print("β No refresh token available. Full re-authentication required.") | |
| else: | |
| print("β Credentials are still valid - no refresh needed.") | |
| except Exception as e: | |
| print(f"π₯ Error: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| if __name__ == "__main__": | |
| main() |