I have a hosted feature service on arcgis.com that is not publicly shared and I need to read the data from a python script. The below script has been running without issue until recently. I now get a 000732 error ("Dataset does not exist or is not supported") when the MakeFeatureLayer_management tool executes. I printed the url to make sure I am passing a url(string) and not an object to the tool and the url is valid so I have no idea what's going on. I also tried generating a token and passing it in the url, but that didn't work either.
Here is my code:
pw = keyring.get_password("scripts", "UserName")
gis = GIS("https://www.arcgis.com", "UserName", pw) # Connect to ArcGIS Online
#token = gis._con.token
layer_item_id = "34a9970d75f448da9898e3237efxxxx" # TM Points AGOL testing layer in my account
layer_item = gis.content.get(layer_item_id)
WebData = layer_item.layers[0]
WebData_url = layer_item.layers[0].url
#auth_url = f"{WebData_url}?token={token}"
print("web url", WebData_url) // a valid url is printed to screen
arcpy.MakeFeatureLayer_management(WebData_url, "WebData") # Create temporary TM Points feature layer
I also updated sharing to public and the code worked, so I know this is an authentication issue and I just need some help understanding what I am doing wrong. I did try using the auth_url in the MakeFeatureLayer_management tool but got the same error.