<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic You do not have permissions to access this resource or perform this operation. (Error Code: 403) in ArcGIS Notebooks Questions</title>
    <link>https://community.esri.com/t5/arcgis-notebooks-questions/you-do-not-have-permissions-to-access-this/m-p/720148#M201</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using ArcGIS Python Notebooks on AGOL to summarize some stats regarding groups in our organization and I am getting the following error message:&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;You do not have permissions to access this resource or perform this operation. (Error Code: 403)
Here is the code:
import pandas as pd
cols=['Group ID','Group Name','Number of Users','Creator Licenses','Other Licenses']
df = pd.DataFrame(columns=cols)

groups=gis.groups.search()

i=0

for group in groups:
 item={}
 
 print(group)
 response = group.get_members()
 num_users=0
 creator_num=0
 noncreator_num=0
 num_items=0
 num_maps=0 
 num_forms=0 #()
 num_tpk=0 #()
 num_wms=0 #()
 num_dashboard=0 #()
 num_webapp=0 #()
 num_sm=0 #()
 
 for group_items in group.content(max_items=10000000):
 num_items=num_items+1
 
 item_type=group_items.type
 
 if (item_type=='Web Map'):
 num_maps=num_maps+1
 if (item_type=='Form'):
 num_forms=num_forms+1
 if (item_type=='Tile Package'):
 num_tpk=num_tpk+1
 if (item_type=='Map Service'):
 num_wms=num_wms+1
 if (item_type=='Map ServiceDashboard'):
 num_dashboard=num_dashboard+1
 if (item_type=='Web Mapping Application'):
 num_webapp=num_webapp+1
 if (item_type=='StoryMap'):
 num_sm=num_sm+1
 
 
 for user in response['users']:
 num_users=num_users+1
 
 user_obj=gis.users.get(username=user)
 
 print(user_obj)
 try:
 user_types=user_obj.user_types()
 
 #items=user_obj.items(folder=None, max_items=1000000)
 
 if (user_types['name']=='Creator'):
 creator_num=creator_num+1
 else:
 noncreator_num=noncreator_num+1
 
 item={'Group Name':group.title,'Number of Users':num_users,'Group ID':group.groupid,'Creator Licenses':creator_num,'Other Licenses':noncreator_num,'Number of Items':num_items,
 'Number of Web Maps':num_maps,'Number of Forms':num_forms,'Number of Tile Packages':num_tpk,'Number of Map Services':num_wms,'Number of Dashboards':num_dashboard,
 'Number of Web Apps':num_webapp,'Number of Story Maps':num_sm}
 df=df.append(item,ignore_index=True)
 i=i+1
 #print(i)
df&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error is showing up when I reach a certain user which happens to be from another organization (our Hub organization) so perhaps this the underlying problem. Is there a way to mitigate this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 06:48:48 GMT</pubDate>
    <dc:creator>AsafEvenPaz</dc:creator>
    <dc:date>2021-12-12T06:48:48Z</dc:date>
    <item>
      <title>You do not have permissions to access this resource or perform this operation. (Error Code: 403)</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/you-do-not-have-permissions-to-access-this/m-p/720148#M201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using ArcGIS Python Notebooks on AGOL to summarize some stats regarding groups in our organization and I am getting the following error message:&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;You do not have permissions to access this resource or perform this operation. (Error Code: 403)
Here is the code:
import pandas as pd
cols=['Group ID','Group Name','Number of Users','Creator Licenses','Other Licenses']
df = pd.DataFrame(columns=cols)

groups=gis.groups.search()

i=0

for group in groups:
 item={}
 
 print(group)
 response = group.get_members()
 num_users=0
 creator_num=0
 noncreator_num=0
 num_items=0
 num_maps=0 
 num_forms=0 #()
 num_tpk=0 #()
 num_wms=0 #()
 num_dashboard=0 #()
 num_webapp=0 #()
 num_sm=0 #()
 
 for group_items in group.content(max_items=10000000):
 num_items=num_items+1
 
 item_type=group_items.type
 
 if (item_type=='Web Map'):
 num_maps=num_maps+1
 if (item_type=='Form'):
 num_forms=num_forms+1
 if (item_type=='Tile Package'):
 num_tpk=num_tpk+1
 if (item_type=='Map Service'):
 num_wms=num_wms+1
 if (item_type=='Map ServiceDashboard'):
 num_dashboard=num_dashboard+1
 if (item_type=='Web Mapping Application'):
 num_webapp=num_webapp+1
 if (item_type=='StoryMap'):
 num_sm=num_sm+1
 
 
 for user in response['users']:
 num_users=num_users+1
 
 user_obj=gis.users.get(username=user)
 
 print(user_obj)
 try:
 user_types=user_obj.user_types()
 
 #items=user_obj.items(folder=None, max_items=1000000)
 
 if (user_types['name']=='Creator'):
 creator_num=creator_num+1
 else:
 noncreator_num=noncreator_num+1
 
 item={'Group Name':group.title,'Number of Users':num_users,'Group ID':group.groupid,'Creator Licenses':creator_num,'Other Licenses':noncreator_num,'Number of Items':num_items,
 'Number of Web Maps':num_maps,'Number of Forms':num_forms,'Number of Tile Packages':num_tpk,'Number of Map Services':num_wms,'Number of Dashboards':num_dashboard,
 'Number of Web Apps':num_webapp,'Number of Story Maps':num_sm}
 df=df.append(item,ignore_index=True)
 i=i+1
 #print(i)
df&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The error is showing up when I reach a certain user which happens to be from another organization (our Hub organization) so perhaps this the underlying problem. Is there a way to mitigate this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:48:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/you-do-not-have-permissions-to-access-this/m-p/720148#M201</guid>
      <dc:creator>AsafEvenPaz</dc:creator>
      <dc:date>2021-12-12T06:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: You do not have permissions to access this resource or perform this operation. (Error Code: 403)</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/you-do-not-have-permissions-to-access-this/m-p/720149#M202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is the error still happening even with this line commented out? When is the error being called?&lt;/P&gt;&lt;PRE style="color: #000000; background-color: #ffffff; border: 0px; font-size: 14px; padding: 1px 0px;"&gt; #items=user_obj.items(folder=None, max_items=1000000)&lt;/PRE&gt;&lt;P&gt;I suspect there would be authorisation issues when attempting to grab all the items associated with the external user.&amp;nbsp;Or maybe it's when you try to get the user type of the external user.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Oct 2020 17:06:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/you-do-not-have-permissions-to-access-this/m-p/720149#M202</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-10-30T17:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: You do not have permissions to access this resource or perform this operation. (Error Code: 403)</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/you-do-not-have-permissions-to-access-this/m-p/720150#M203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The error is happening when I call&amp;nbsp;user_types=user_obj.user_types() so it is related to the user type of the external user. Can I exclude users that are not from my organization when I make this call?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Oct 2020 17:13:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/you-do-not-have-permissions-to-access-this/m-p/720150#M203</guid>
      <dc:creator>AsafEvenPaz</dc:creator>
      <dc:date>2020-10-30T17:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: You do not have permissions to access this resource or perform this operation. (Error Code: 403)</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/you-do-not-have-permissions-to-access-this/m-p/720151#M204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#user" title="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#user"&gt;arcgis.gis module — arcgis 1.8.2 documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to the ArcGIS Python API doc the user object should have an orgId property (user.orgId) but I haven't been able to get that to work - I'll look into that separately. One option is that you could ignore the error&amp;nbsp;by surrounding the logic in a try/catch like below and printing the error message rather than having the code break because of it:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="512178" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/512178_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if you have anymore questions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Oct 2020 18:05:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/you-do-not-have-permissions-to-access-this/m-p/720151#M204</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-10-30T18:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: You do not have permissions to access this resource or perform this operation. (Error Code: 403)</title>
      <link>https://community.esri.com/t5/arcgis-notebooks-questions/you-do-not-have-permissions-to-access-this/m-p/720152#M205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks - the "try catch" option&amp;nbsp;worked &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Oct 2020 18:14:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-notebooks-questions/you-do-not-have-permissions-to-access-this/m-p/720152#M205</guid>
      <dc:creator>AsafEvenPaz</dc:creator>
      <dc:date>2020-10-30T18:14:36Z</dc:date>
    </item>
  </channel>
</rss>

