garmin_auth.py 784 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env python
  2. import os
  3. import sys
  4. import getpass
  5. import garth
  6. domain = input("Garmin domain [garmin.com]: ") or 'garmin.com'
  7. username = input("Username (e-mail): ")
  8. if not sys.stdin.isatty(): # This terminal cannot support input without displaying text
  9. print(f'*WARNING* The current shell ({os.name}) cannot support hidden text entry.')
  10. print(f'Your password entry WILL BE VISIBLE.')
  11. print(f'If you are running a bash shell under windows, try executing this program via winpty:')
  12. print(f'>winpty python {sys.argv[0]}')
  13. password = input("Password (will be shown): ")
  14. else:
  15. password = getpass.getpass("Password: ")
  16. garth.configure(domain=domain)
  17. try:
  18. garth.login(username, password)
  19. garth.save('./garth')
  20. except Exception as e:
  21. print(e)