<?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 Discrepancies accessing AGO Community users through REST API using PortalPy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164331#M12591</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using the Python Module, &lt;A href="https://github.com/Esri/portalpy"&gt;PortalPy&lt;/A&gt;, found on GitHub to write scripts to run administrative tasks in ArcGIS Online.&amp;nbsp; PortalPy is great because it keeps me from having to access the REST API myself, which is something I'm not very familiar with.&amp;nbsp; But I'm running into discrepancies in what is being returned and I'm not sure whether the inconsistency is within the REST API or the PortalPy module.&amp;nbsp; There are two functions within the module - &lt;STRONG&gt;get_org_users&lt;/STRONG&gt; and &lt;STRONG&gt;get_user&lt;/STRONG&gt; - that I am having trouble with at the moment&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Our organization has implemented custom roles.&amp;nbsp; I have a script that stores each member's information in json format so that I can access relevant information outside of AGO.&amp;nbsp; The problem is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;EM style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif;"&gt;get_org_users returns true 'role' for every user (including custom roles) but returns an empty list for 'groups' for each user. get_user returns only ESRI-defined 'role' for each user (custom role value returned defaults back to ESRI-defined template that custom role is based on?) but returns a populated dictionary for 'groups' for each user.&lt;/EM&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif;"&gt;I need to have the user's true 'role' and 'groups' in the same json file.&amp;nbsp; Can anybody explain why the two functions do not produce the same results?&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif;"&gt;Heath&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Dec 2014 19:54:50 GMT</pubDate>
    <dc:creator>HeathBrackett1</dc:creator>
    <dc:date>2014-12-05T19:54:50Z</dc:date>
    <item>
      <title>Discrepancies accessing AGO Community users through REST API using PortalPy</title>
      <link>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164331#M12591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using the Python Module, &lt;A href="https://github.com/Esri/portalpy"&gt;PortalPy&lt;/A&gt;, found on GitHub to write scripts to run administrative tasks in ArcGIS Online.&amp;nbsp; PortalPy is great because it keeps me from having to access the REST API myself, which is something I'm not very familiar with.&amp;nbsp; But I'm running into discrepancies in what is being returned and I'm not sure whether the inconsistency is within the REST API or the PortalPy module.&amp;nbsp; There are two functions within the module - &lt;STRONG&gt;get_org_users&lt;/STRONG&gt; and &lt;STRONG&gt;get_user&lt;/STRONG&gt; - that I am having trouble with at the moment&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Our organization has implemented custom roles.&amp;nbsp; I have a script that stores each member's information in json format so that I can access relevant information outside of AGO.&amp;nbsp; The problem is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;EM style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif;"&gt;get_org_users returns true 'role' for every user (including custom roles) but returns an empty list for 'groups' for each user. get_user returns only ESRI-defined 'role' for each user (custom role value returned defaults back to ESRI-defined template that custom role is based on?) but returns a populated dictionary for 'groups' for each user.&lt;/EM&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif;"&gt;I need to have the user's true 'role' and 'groups' in the same json file.&amp;nbsp; Can anybody explain why the two functions do not produce the same results?&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif;"&gt;Heath&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 19:54:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164331#M12591</guid>
      <dc:creator>HeathBrackett1</dc:creator>
      <dc:date>2014-12-05T19:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancies accessing AGO Community users through REST API using PortalPy</title>
      <link>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164332#M12592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;A href="https://community.esri.com/migrated-users/35283"&gt;Heath Brackett&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The method call to get_org_users makes a REST call to: &amp;lt;PortalURL&amp;gt;/sharing/rest/portals/self/users&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where as the method call to get_user makes a REST call to: &amp;lt;PortalURL&amp;gt;/sharing/rest/community/users/&amp;lt;USERNAME&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Dec 2014 17:33:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164332#M12592</guid>
      <dc:creator>AlexanderNohe1</dc:creator>
      <dc:date>2014-12-10T17:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancies accessing AGO Community users through REST API using PortalPy</title>
      <link>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164333#M12593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I understand that.&amp;nbsp; But I don't understand why the responses provide different results. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The user['role'] property honors custom roles when accessed via &amp;lt;PortalURL&amp;gt;/sharing/rest/portals/self/users.&amp;nbsp; If you access the user['role'] property via &amp;lt;PortalURL&amp;gt;/sharing/rest/community/users/&amp;lt;USERNAME&amp;gt;, the response is never a custom role - it seems to always default to the ESRI standard role template that was used to create the custom role.&amp;nbsp; Why isn't the same value populated in each location? The REST API documentation does not address this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Conversely, according to the REST API documentation, user['groups'] property coming from .../portals/self/users is a list of the groups that user is a member of, but it always returns an empty list (why is this list empty?).&amp;nbsp; The user['groups'] property coming from .../community/users/&amp;lt;USERNAME&amp;gt; returns an array of all of the groups that a user is a member of.&amp;nbsp; Is there a reason that the user['groups'] property must be a list instead of an array when accessed via .../portals/self/users?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is all very confusing.&amp;nbsp; I get the feeling that ESRI is not aware that these calls aren't returning appropriate results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Heath&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Dec 2014 16:15:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164333#M12593</guid>
      <dc:creator>HeathBrackett1</dc:creator>
      <dc:date>2014-12-11T16:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancies accessing AGO Community users through REST API using PortalPy</title>
      <link>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164334#M12594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does it run only in ArcGIS 10.5?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In 10.2.2 the library "import portalpy" is missing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Mar 2017 19:53:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164334#M12594</guid>
      <dc:creator>JoseSanchez</dc:creator>
      <dc:date>2017-03-20T19:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancies accessing AGO Community users through REST API using PortalPy</title>
      <link>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164335#M12595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Portlapy is an open source library that can be located here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://github.com/Esri/portalpy" title="https://github.com/Esri/portalpy"&gt;GitHub - Esri/portalpy: A module that allows you to administer Portal for ArcGIS and ArcGIS Online.&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This library is not included with ArcGIS Desktop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Mar 2017 12:33:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164335#M12595</guid>
      <dc:creator>AlexanderNohe1</dc:creator>
      <dc:date>2017-03-21T12:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancies accessing AGO Community users through REST API using PortalPy</title>
      <link>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164336#M12596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can I use my&amp;nbsp;AGOL to test this list_admins.py?&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;A href="http://mdc.maps.arcgis.com/arcgis"&gt;&lt;SPAN style="color: #0066cc; text-decoration: underline;"&gt;http://[my Organization].maps.arcgis.com&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; or does it work only with a local&amp;nbsp; portal?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to test it with:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;portalUrl&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = "&lt;A href="http://mdc.maps.arcgis.com/arcgis"&gt;http://[my Organization].maps.arcgis.com/arcgis&lt;/A&gt;"&amp;nbsp;&amp;nbsp; or&amp;nbsp; "&lt;A href="http://mdc.maps.arcgis.com/arcgis"&gt;&lt;SPAN style="color: #0066cc; text-decoration: underline;"&gt;http://[my Organization].maps.arcgis.com&lt;/SPAN&gt;&lt;/A&gt;"&lt;BR /&gt;portalAdminUser&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = "my User Id"&lt;BR /&gt;portalAdminPassword = "my Password"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and it shows the following error message:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "C:\Workspace\portalpy-master\list_admins.py", line 32, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; portal = portalpy.Portal(portalUrl, portalAdminUser, portalAdminPassword)&lt;BR /&gt;&amp;nbsp; File "C:\Workspace\portalpy-master\portalpy.py", line 121, in __init__&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; referer, proxy_host, proxy_port)&lt;BR /&gt;&amp;nbsp; File "C:\Workspace\portalpy-master\portalpy.py", line 1800, in __init__&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.login(username, password, expiration)&lt;BR /&gt;&amp;nbsp; File "C:\Workspace\portalpy-master\portalpy.py", line 1815, in login&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newtoken = self.generate_token(username, password, expiration)&lt;BR /&gt;&amp;nbsp; File "C:\Workspace\portalpy-master\portalpy.py", line 1809, in generate_token&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; resp = self.post('generateToken', postdata, ssl=True)&lt;BR /&gt;&amp;nbsp; File "C:\Workspace\portalpy-master\portalpy.py", line 2016, in post&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; resp = opener.open(url, data=encoded_postdata)&lt;BR /&gt;&amp;nbsp; File "C:\Python27\ArcGISx6410.2\lib\urllib2.py", line 410, in open&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; response = meth(req, response)&lt;BR /&gt;&amp;nbsp; File "C:\Python27\ArcGISx6410.2\lib\urllib2.py", line 523, in http_response&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'http', request, response, code, msg, hdrs)&lt;BR /&gt;&amp;nbsp; File "C:\Python27\ArcGISx6410.2\lib\urllib2.py", line 448, in error&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return self._call_chain(*args)&lt;BR /&gt;&amp;nbsp; File "C:\Python27\ArcGISx6410.2\lib\urllib2.py", line 382, in _call_chain&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = func(*args)&lt;BR /&gt;&amp;nbsp; File "C:\Python27\ArcGISx6410.2\lib\urllib2.py", line 531, in http_error_default&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)&lt;BR /&gt;HTTPError: HTTP Error 404: Not Found&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Mar 2017 13:04:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164336#M12596</guid>
      <dc:creator>JoseSanchez</dc:creator>
      <dc:date>2017-03-21T13:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancies accessing AGO Community users through REST API using PortalPy</title>
      <link>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164337#M12597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe that you should be able to use your ArcGIS Online account to access.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would check three things:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Ensure that your username matches exactly how it appears in ArcGIS Online (case sensitivity).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Ensure that you are not restricted to SSL Only in your organization.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) Ensure that you are logged in with a user that has those permissions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I am not a member of the python team, I would encourage that you direct your questions to the issues section of the repository:&amp;nbsp;&lt;A class="link-titled" href="https://github.com/Esri/portalpy/issues" title="https://github.com/Esri/portalpy/issues"&gt;Issues · Esri/portalpy · GitHub&lt;/A&gt;&amp;nbsp; &amp;nbsp;Here, you will be able to reach out directly to the developers of this module and they can help answer questions / resolve issues with the source code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Mar 2017 13:55:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/discrepancies-accessing-ago-community-users/m-p/164337#M12597</guid>
      <dc:creator>AlexanderNohe1</dc:creator>
      <dc:date>2017-03-21T13:55:39Z</dc:date>
    </item>
  </channel>
</rss>

