Link Access Profiles to application through API

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 !

Wich error message do you have ?

No specific error message, but when searching in the result the number of APs added to the app, we are finding that it is not the number requested. Like if the API call was not able to manager all the Access Profiles

Is there anyone who already did this ?

Regards

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.