item.shared_with Groups permissions issue
See original GitHub issueDescribe Issue There appears to be a permissions issue when accessing the groups an item is shared with. I can still access the ‘everyone’ and ‘org’ values without any issues. This only occurs for 23 out of 198 feature services. All items are owned by the same user, and after comparing all of the items that cause the error and the items that work without issue, there don’t appear to be any patterns or similarities that would cause these items to fail.
History Within the past year all layers on AGO transferred from one account to another. I have verified that the account I’m logging in through and the owner of feature services the issue occurs for are the same.
Platform Windows 10 Pro Python v3.7.9 ArcGIS API v1.8.5 Updated to Python v3.7.11 and API v1.9.1 and the issue remains
Example of the error
item = gis.content.search(query='id:[itemId_here]')
for k,v in item[0].shared_with.items():
print(k,v)
everyone False
org True
groups Traceback (most recent call last):
File "<pyshell#60>", line 2, in <module>
print(k,v)
File "C:\Users\...\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py", line 6343, in __repr__
return '<%s title:"%s" owner:%s>' % (type(self).__name__, self.title, self.owner)
File "C:\Users\...\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py", line 6321, in __getattr__
self._hydrate()
File "C:\Users\...\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\__init__.py", line 6314, in _hydrate
groupdict = self._portal.get_group(self.groupid)
File "C:\Users\...\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\_impl\_portalpy.py", line 949, in get_group
return self.con.post('community/groups/' + group_id, self._postdata())
File "C:\Users\...\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 720, in post
force_bytes=kwargs.pop('force_bytes', False))
File "C:\Users\...\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 514, in _handle_response
self._handle_json_error(data['error'], errorcode)
File "C:\Users\...\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 536, in _handle_json_error
raise Exception(errormessage)
Exception: You do not have permissions to access this resource or perform this operation.
(Error Code: 403)
The error is exactly the same if I call ‘groups’ with the code below:
item[0].shared_with['groups']
To Reproduce The below code can be run to find feature services within your AGO account that this error occurs for.
from arcgis.gis import GIS
gis = GIS('https://www.arcgis.com',[username],[password])
user = gis.users.me
folders = user.folders
for f in folders:
items = user.items(f['title'])
for item in items:
groups = []
try:
if item.shared_with['groups'] != []:
for g in item.shared_with['groups']:
groups.append(g.title)
except:
print(item.id)
Issue Analytics
- State:
- Created a year ago
- Comments:17 (6 by maintainers)
Top GitHub Comments
Maybe it’s been corrected already in 2.0.0. I think ArcGIS Pro v2.9.2 installs ArcGIS API v1.9.1 by default. I’ll update to the latest API version and see if the issue is still presenting. If so, maybe it’s something specific to my AGO account.
Closing.