-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_user.py
More file actions
31 lines (27 loc) · 793 Bytes
/
create_user.py
File metadata and controls
31 lines (27 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import requests
import json
import os
# Load environment variables
from dotenv import load_dotenv
load_dotenv()
# Ensure AUTHENTIK_BASE_URL and AUTHENTIK_TOKEN are set in your .env file
AUTHENTIK_BASE_URL = os.getenv("AUTHENTIK_URL")
api_token = os.getenv("AUTHENTIK_API_TOKEN")
url = "http://localhost:80/api/v3/core/users/"
payload = json.dumps({
"username": "string_testing_23453",
"name": "string3453",
"is_active": True,
"last_login": "2024-07-29T15:51:28.071Z",
"email": "user@example.com",
"attributes": {},
"path": "string",
"type": "internal"
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': f'Bearer {api_token}'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)