I am writing a python script to run nightly that exports Feature Layers from AGOL to our local drives. We have a couple of members that are updating their own feature layers, and I am trying to access these. I can get the script to work using....shAGOL = arcrest.AGOLTokenSecurityHandler(username, password).....if the username and password are the AGOL members. However, if I try to use the AGOL Administrator username and password, it can't access the members feature layers. Is there a way to get the script to work using just the Administrator credentials instead of having to ask each member for their passwords? Any help would be appreciated! I am very new to ArcREST, so I am sure that I am missing something.
I am not sure if there is enough to go on. It could be authentication isn't the issue but how some of the rest of the code is working when logged in as different users, not necessarily an administrator non-administrator issue. What happens when logged in as an administrator? Does the script error? Are the results different than expected?
We got it figured out. It was later on in the coding. It was a matter of changing the line
user = admin.content.users.user(username=item.owner) to
user = admin.content.users.user(username=username).
It does lead me to another question, though. The purpose of our python code is to back up the feature layers that others are creating and updating on AGOL. Right now, the python code looks for a specific ItemID....is there a way to have the code go into a Members content and list all of their feature layers and itemIDs? This would be ideal since we may not be notified every time someone creates a new layer. Does that make sense? I haven't found a script that does it that way.
Just to follow up on this, I did get the script working. It was a matter of adding this piece before the user.exportItem.....
admin = arcrest.manageorg.Administration(securityHandler=shAGOL)
content = admin.content
portal = admin.portals.portalSelf
commUsers = portal.users(start=1, num=100)
commUsers = commUsers['users']
for commUser in commUsers:
user = admin.content.users.user(commUser.username)
for userItem in user.items:
sItem = userItem.id
sName = userItem.name
sType = userItem.type
sUser = commUser.username
if sUser == "YakimaStormwater":
if sType == "Feature Service":