HOW TO

Bulk update stored credentials for items in Portal for ArcGIS using the ArcGIS API for Python

Last Published: May 24, 2024

Summary

When there are a lot of services added to ArcGIS Enterprise with stored credentials, and those credentials get updates, it could be very time-consuming to update them manually. 

Procedure

The below script automates updating the credentials by finding the items added to Portal for ArcGIS with stored credentials, and updating the credentials to the desired ones.

from arcgis.gis import GIS

gis = GIS("https://dns.esri.com/portal", "username", "password")
token = gis._con.token

content = gis.content.search(query="",max_items=10000)

def updateStoredCredentials(content):
    for item in content:
        if 'sourceUrl' in item:
            item = gis.content.get(item.id)
            properties = {"url":item['sourceUrl'],
                          "serviceUsername":"updatedusername",
                          "servicePassword":"updatedpassword",
                          "token":token,
                          }
            item.update(item_properties=properties)
            print(f"Successfully updated {item}")
            
updateStoredCredentials(content)

Article ID: 000032506

Software:
  • ArcGIS API for Python
  • ArcGIS Enterprise

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options