This is the completed sample for the Share your content ArcGIS DevLab. ArcGIS DevLabs are short introductory tutorials to guide you through the three phases of building geospatial apps: Data, Design, Develop.
Please complete the Create data lab if you have not done so already. You will use the output feature layer from this lab to learn how to find and share an item.
from arcgis.gis import *
Log into ArcGIS Online by making a GIS connection using your developer account. Replace username
and password
with your own credentials
dev_gis = GIS("https://www.arcgis.com", "username", "password")
Search for the Griffith Park Access layer used in the Create data lab DevLab.
feature_layer_srch_results = dev_gis.content.search(query='title: "Griffith*" AND type: "Feature Service"')
feature_layer_srch_results
Retrieve the feature layer collection item from the list of results. To check the sharing permissions, click the thumbnail link to open the Item Details page and find Shared with under Details on the right.
feature_layer_coll_item = feature_layer_srch_results[0]
feature_layer_coll_item
Update the sharing permissions of the layer so that it's available to everyone. You can verify the update by refreshing the thumbnail link!
feature_layer_coll_item.share(everyone=True)