Select to view content in your preferred language

ArcGIS Online Add-On License Python Script

321
2
10-14-2025 06:07 AM
bennein
New Contributor

Hello,

I administer an ArcGIS Online Organization for a large higher ed environment. ESRI's license/add-on rearranging caused our users to be assigned an add-on license that no longer exists. It's causing issues with access to software. For example, ArcGIS Urban no longer is a stand alone add-on. Our users have the license but since it's still assigned as separate add-on, I have to manually turn off that expired license for Urban to work. This is just one example. 

I've used ArcGIS API for Python before for credit management and I was wondering if there was a way to develop a script to mass turn off an assigned add-on license for users? I have over 7000+ users and the default ArcGIS Online GUI only allows me (as an admin) to turn off the license for 50 users at a time. 

I'd appreciate any direction with this as I browse the API. 

Thanks!

0 Kudos
2 Replies
Clubdebambos
MVP Regular Contributor

Hi @bennein,

I have never tried something like this but here is how it might go...

from arcgis.gis import GIS

## access ArcGIS Online
agol = GIS("home")

## get the License object for ArcGIS Pro
## if ArcGIS Urban is not a part of the ArcGIS Pro entitlemnents
## then it is its own license and you relace ArcGIS Pro with ArcGIS Urban (or the correct keyword)
pro_license = agol.admin.license.get("ArcGIS Pro")

## print out the entitlements for a user you know has access so you
## can get the ArcGIS Urban keyword.
print(pro_license.user_entitlement("USERNAME"))

###############################################################
##   RUN TO HERE FIRST SO YOU HAVE THE ARCGIS URBAN KEYWORD  ##
###############################################################

## get a list of all users as User objects
users = agol.users.search(max_users=10000)

## for each user
for user in users:
    ## revoke the entitlement
    status = pro_license.revoke(
        username = user.username,
        entitlements = "ARCGIS_URBAN_KEYWORD"
    )

    print(status)

Inspiration from here.

All the best,

Glen

 

~ learn.finaldraftmapping.com
PeterKnoop
MVP Regular Contributor

@bennein, if you are still seeing a duplicate license warning in the ArcGIS Online GUI, then you may be able to revoke all of the license in one-go via that warning message. For more details, please see Removing Duplicate add-on license messages in Education ArcGIS Online Organizations.

Since ArcGIS Urban was previously delivered as part of an application bundle, the ArcGIS Urban Suite (which included CityEngine and Urban), revoking the bundle programmatically is different than for a license. (See the Bundle class in the ArcGIS API for Python.)

Here's an example that revokes the ArcGIS Urban Suite bundle from all users who currently have it:

# Retrieve available bundles for your gis.
bundles = gis.admin.license.bundles

# Extract the bundle for ArcGIS Urban Suite
bundle = [ b for b in bundles if b.properties.name == "ArcGIS Urban Suite" ][0]

# Retrieve list of users who have the bundle
users = bundle.users

# Revoke the bundle from that list of users
bundle.revoke(users)

 Also, double-check that you are no longer assigning the ArcGIS Urban Suite via New member defaults.