import requests ip="" domain_name="" project_name="" user_name="" password="" def get_token(ip,domain_name,project_name,user_name,password): url=f"http://{ip}:5000/v3/auth/tokens" auth_data = { "auth": { "identity": { "methods": ["password"], "password": { "user": { "name": user_name, "domain": {"name": domain_name}, "password": password } } }, "scope": { "project": { "name": project_name, "domain": {"name": domain_name} } } } } resp=requests.post(url=url,json=auth_data) token=resp.headers['X-Subject-Token'] return token