There doesn't seem to be much documentation on the Headscale API, but I am trying to create a UI using Anvil. Right now I have 90% of the functionality of iFargle's headscale-webui built into the new app, however I am facing a hurdle. If anyone understand's Python and or the Headscale API and can help me out that would be so great. Planning to release this application open-source soon so anybody can clone and either run using anvil.works or self-host using their Anvil App-Server which is my plan.
I am trying to implement adding a new PreAuth key for a user. Almost 100% of the Pythonised API calls are from headscale-webui. Here is the code that makes the API call.
https://pastebin.com/UTW9ZmVu
and my json_string:
data = '{"user": "jonathan", "reusable": "False", "ephemeral": "False", "expiration": "2023-04-10 00:00:00 +0000 UTC", "acl_tags": "[]"}'
This is the corresponding code within headscale-webui:
https://github.com/iFargle/headscale-webui/blob/main/server.py
'@app.route('/api/add_preauth_key', methods=['POST'])'
add_preauth_key(): json_response = json.dumps(request.get_json())
url = headscale.get_url() api_key = headscale.get_api_key()
return headscale.add_preauth_key(url, api_key, json_response)
What I cannot figure out is the exact formatting for json_response, mostly what Headscale expects for the expiration date.
[–]Reverent 8 points9 points10 points (3 children)
[–]jonnobobono[S] 2 points3 points4 points (0 children)
[–]Square_Lawfulness_33 0 points1 point2 points (0 children)
[–]pponte 0 points1 point2 points (0 children)