import json import pyotp totp=pyotp.TOTP("PZKBPTHDGSLZBKIZ") request={} request['name'] = "info@ungleich.ch" request['verifyname'] = request['name'] request['token'] = totp.now() request['verifytoken'] = request['token'] request['realm'] = "ungleich-admin" request['verifyrealm'] = request['realm'] print(json.dumps(request)) data = json.dumps(request) with open("outdata", "w") as fd: fd.write(data) fd.write("\n")