auto_api_keys/default.py

22 lines
495 B
Python
Raw Permalink Normal View History

2022-10-22 23:34:58 +02:00
#!/usr/bin/env python3
"""Sample code
Get API Keys and write this to an env file
"""
from fortytwo_auto_api import fortytwo_auto_keys
import secret
fortytwo = fortytwo_auto_keys(
login=secret.LOGIN_42,
password=secret.PASSWORD_42,
app_url=secret.APP_URL,
otp_secret=secret.OTPSECRET_42,
)
fortytwo.auto()
api_keys = fortytwo.keys
with open("env_file", "w+") as f:
f.write(f"OAUTH2_INTRA42_CLIENT_ID={api_keys['uid']}\n")
f.write(f"OAUTH2_INTRA42_CLIENT_SECRET={api_keys['secret']}\n")