Skip to content

Commit

Permalink
Google Authenticator in Python
Browse files Browse the repository at this point in the history
Desktop Python Google Authenticator script with json secrets (while loop).
  • Loading branch information
atomjoy committed Feb 23, 2024
1 parent 96b9107 commit a6dfc74
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions 2fa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/python

# Install
# sudo apt install python3 python3-pyotp -y

import time, json, os
import pyotp

def main():
while True:
rel = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
with open(os.path.join(rel,'secrets.json'), 'r') as f:
secrets = json.load(f)
for label, key in sorted(list(secrets.items())):
code = pyotp.TOTP(key).now()
print("Label {} Secret {} Code {}".format(label, key, code))
time.sleep(30)

if __name__ == "__main__":
main()

0 comments on commit a6dfc74

Please sign in to comment.