Skip to content

Instantly share code, notes, and snippets.

@adw0rd
Created October 1, 2014 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adw0rd/6d555c85f72616eb18cb to your computer and use it in GitHub Desktop.
Save adw0rd/6d555c85f72616eb18cb to your computer and use it in GitHub Desktop.
from totp_auth import TotpAuth
def main(secret=None):
if not secret:
# WHEN SIGN UP
ta = TotpAuth()
else:
# WHEN SIGN IN
ta = TotpAuth(secret)
# SHOW SECRET AND QR CODE
qr = ta.qrcode('adw0rd@adw0rd.com')
print 'SECRET: ', ta.secret
qr._img.show()
# CHECK TOKEN
while True:
token = raw_input('Please input the token from Google Authenticator: ')
if ta.valid(token):
print "SUCCESS"
else:
print "FAILED"
if __name__ == '__main__':
import sys
main(*sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment