uotp/scripts/create-auth.py

20 lines
603 B
Python
Raw Normal View History

import requests
import pyotp
import json
import decouple
import argparse
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("admin_seed")
args = arg_parser.parse_args()
r = requests.post("http://localhost:{}/create".format(decouple.config("PORT")),
json={
"name": "auth",
"realm": ["ungleich-auth"],
"admin_name": "admin",
"admin_realm": "ungleich-admin",
"admin_token": pyotp.TOTP(args.admin_seed).now()
})
print(json.loads(r.content.decode("utf-8")))