Hello, everyone
I’m trying to create a script to automate the creation of access profiles on my ISC enviroment, i followed the sailpoint documentation to build the script and also tried to do the request through a http client (insomnia) but i always get the following error:
I already checked the content and tried diferent identities that are being used as owners in others existing access profiles, here is the script i’m trying to execute:
import csv
import subprocess
import requests
import json
# ===== CONFIG =====
BASE_URL = "https://my-tenant.api.identitynow.com"
CLIENT_ID = "my-client-id"
CLIENT_SECRET = "my-client-secret"
CSV_FILE = "entitlements.csv"
def get_token():
url = f"{BASE_URL}/oauth/token"
payload = {
"grant_type": "client_credentials",
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET
}
response = requests.post(url, data=payload)
if response.status_code != 200:
raise Exception(f"Erro ao gerar token: {response.text}")
return response.json()["access_token"]
def criar_access_profile(linha, token):
name = linha["name"].strip()
description = linha["description"].strip() or f"Acesso {linha['name']}"
source_id = linha["sourceId"]
entitlement_id = linha["entitlementId"]
name = name.replace("|", "-")
payload = json.dumps({
"name": name,
"description": description,
"enabled": True,
"owner": {
"type": "IDENTITY",
"id": "d4ca5a081b154a5d9174578ec0586064",
"name": "Leticia Ferreira"
},
"source": {
"id": source_id,
"type": "SOURCE",
"name": "Active Directory"
},
"entitlements": [
{
"type": "ENTITLEMENT",
"id": entitlement_id,
"name": name
}
],
"requestable": True,
"accessRequestConfig": {
"commentsRequired": True,
"denialCommentsRequired": True,
"reauthorizationRequired": True,
"requireEndDate": True,
"maxPermittedAccessDuration": {
"value": 6,
"timeUnit": "MONTHS"
},
"approvalSchemes": [
{
"approverType": "GOVERNANCE_GROUP",
"approverId": "b95932c7-251e-4343-8232-f9acfdcf10eb"
}
]
},
"revocationRequestConfig": {
"approvalSchemes": [
{
"approverType": "GOVERNANCE_GROUP",
"approverId": "b95932c7-251e-4343-8232-f9acfdcf10eb"
}
]
},
})
command = [
"curl",
"-s",
"-X", "POST",
f"{BASE_URL}/v3/access-profiles",
"-H", "Content-Type: application/json",
"-H", f"Authorization: Bearer {token}",
"-d", payload
]
result = subprocess.run(command, capture_output=True, text=True)
if result.returncode == 0:
print(f"✅ Criado: {name}")
if result.stdout:
print(f"🔎 Response: {result.stdout}")
else:
print(f"❌ Erro ao criar {name}: {result.stderr}")
def processar():
token = get_token()
with open(CSV_FILE, newline='', encoding='utf-8-sig') as file:
reader = csv.DictReader(file)
for linha in reader:
try:
criar_access_profile(linha, token)
except Exception as e:
print(f"❌ Erro linha {linha}: {str(e)}")
if __name__ == "__main__":
processar()






