initial gitea commit

This commit is contained in:
Lucas Jensen
2024-06-26 19:19:20 -07:00
commit e830445d02
47 changed files with 10936 additions and 0 deletions

46
server/helpers.py Normal file
View File

@@ -0,0 +1,46 @@
import os
from dotenv import load_dotenv
origins = [
"http://localhost",
"http://localhost:3000",
"https://localhost:3000",
"https://lucasjensen.me/",
"https://lucasjensen.me",
"https://www.lucasjensen.me/",
"https://www.lucasjensen.me",
]
def get_token() -> str:
import http.client
import json
load_dotenv()
client_id = os.getenv("CLIENT_ID")
client_secret = os.getenv("CLIENT_SECRET")
conn = http.client.HTTPSConnection("lucasjensen.us.auth0.com")
payload = (
'{"client_id":"'
+ f"{client_id}"
+ '","client_secret":"'
+ f"{client_secret}"
+ '","audience":"'
+ f"https://api.lucasjensen.me/"
+ '","grant_type":"client_credentials"}'
)
headers = {"content-type": "application/json"}
conn.request("POST", "/oauth/token", payload, headers)
res = conn.getresponse()
data = res.read()
body = json.loads(data.decode("utf-8"))
return body["access_token"]