14 lines
559 B
Python
14 lines
559 B
Python
import requests
|
|
import json
|
|
import urllib3
|
|
urllib3.disable_warnings()
|
|
|
|
url = "https://140.44.4.71:9443/api/auth"
|
|
res = requests.post(url, json={"username": "admin", "password": "Cfxg0GqDfocWcteE"}, verify=False)
|
|
jwt = res.json().get("jwt")
|
|
headers = {"Authorization": f"Bearer {jwt}"}
|
|
|
|
r_create = requests.post("https://140.44.4.71:9443/api/users/1/tokens", headers=headers, json={"description": "homepage-dashboard", "password": "Cfxg0GqDfocWcteE"}, verify=False)
|
|
print("Create token status:", r_create.status_code)
|
|
print("Token response:", r_create.json())
|