-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-user.py
32 lines (26 loc) · 906 Bytes
/
create-user.py
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
32
import requests
import json
# Set your Auth0 domain and token
domain = 'your_domain.us.auth0.com'
token = 'your-valid-token'
# Set the user's information
user_info = {
'email': 'patrik.duch@supermail.com',
'password': 'superman-patrik-duch',
'connection': 'Username-Password-Authentication', # Change this to your connection name
}
# Convert the user information to JSON
user_info_json = json.dumps(user_info)
# Create the header for the request
headers = {
'Authorization': f'Bearer {token}',
'content-type': 'application/json'
}
# Send the POST request to the Auth0 API
response = requests.post(f'https://{domain}/api/v2/users', headers=headers, data=user_info_json)
# Check the response
if response.status_code == 201:
print('User created successfully.')
else:
print('Failed to create user. Status code:', response.status_code)
print('Response:', response.json())