Hello,
We’ve been trying to add Access Profile to Application through API since several Weeks, but we are facing issue.
Sometimes our function is adding 80% of the AP, sometimes less, but we have never found a way to add 100% of our AP to an app through API. For information, we have already raised our limit of AP to be linked with app to ensure we can as many AP that we need in our context. Also, we are aware of the risk to use private API, but we really want to automate this part with some scripts.
This is our code :
def add_access_profile_to_app(app_name, access_profile_ids, tkn):
# Get app id
app_id = get_app_id(app_name, tkn)
# Get app details
url = "https://" + tenant_id + ".api.identitynow.com/cc/api/app/getAccessProfiles/" + app_id
headers = {'Authorization': 'Bearer ' + tkn}
r = requests.request("GET", url, headers=headers)
app = json.loads(r.text)
# Adding access profiles to the application
url = "https://" + tenant_id + ".api.identitynow.com/cc/api/org/getPendingIdentityTasks"
headers = {'Authorization': 'Bearer ' + tkn, 'Content-Type': 'application/json'}
r = requests.request("GET", url, headers=headers)
r = json.loads(r.text)
while r != []:
time.sleep(1)
url = "https://" + tenant_id + ".api.identitynow.com/cc/api/org/getPendingIdentityTasks"
headers = {'Authorization': 'Bearer ' + tkn, 'Content-Type': 'application/json'}
r = requests.request("GET", url, headers=headers)
r = json.loads(r.text)
try:
url = "https://" + tenant_id + ".api.identitynow.com/cc/api/app/update/" + app_id
headers = {'Authorization': 'Bearer ' + tkn, 'Content-Type': 'application/json'}
app["accessProfileIds"] = access_profile_ids
payload = json.dumps(app)
r = requests.request("POST", url, headers=headers, data=payload)
r = json.loads(r.text)
except:
pass
Thanks for your help !