<?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>idea Validate whether user is signed-in to ArcGIS Online\Portal with arcpy in ArcGIS Enterprise Ideas</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-ideas/validate-whether-user-is-signed-in-to-arcgis/idi-p/1479403</link>
    <description>&lt;P&gt;When working with data and layers from ArcGIS Portal, users must be signed in to create new versions, perform edits, and post new changes. Given that each user has a specific role within the organization, it is crucial to ensure the correct user is signed in before any operations are performed. Currently, there is no straightforward Pythonic method for this validation. Implementing such a validation method would allow developers to ensure that the correct user is signed in and has the necessary permissions to edit the data even before starting an editing session.&lt;/P&gt;&lt;P&gt;This idea came to me after reading a &lt;A href="https://community.esri.com/t5/arcgis-enterprise-questions/check-if-the-user-logged-in-to-arcgis-online-or/m-p/1467338#M39497" target="_self"&gt;community question&lt;/A&gt;. In response, I suggested a workaround using the role value returned from the&lt;FONT color="#FF6600"&gt;&lt;EM&gt;&amp;nbsp;arcpy.GetPortalInfo&lt;/EM&gt;&lt;/FONT&gt; function.&lt;/P&gt;&lt;P&gt;My suggested idea is to add the username as a key in the output dictionary of GetPortalInfo. This way, developers can build tools that works only if a user is signed-in.&lt;/P&gt;&lt;P&gt;Another suggested method is to retrieve the user information from the &lt;EM&gt;&lt;FONT color="#FF6600"&gt;ArcGISProject&lt;/FONT&gt; &lt;/EM&gt;object in the &lt;EM&gt;&lt;FONT color="#FF6600"&gt;arcpy.mp module&lt;/FONT&gt;&lt;/EM&gt;. For example:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcpy.mp import ArcGISProject

my_project = ArcGISProject('current')
#option1
current_user:str = my_project.loggedUser 
#option2
condition: bool = my_project.isUserLogged&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 May 2024 11:05:38 GMT</pubDate>
    <dc:creator>Ofir_Mazor</dc:creator>
    <dc:date>2024-05-28T11:05:38Z</dc:date>
    <item>
      <title>Validate whether user is signed-in to ArcGIS Online\Portal with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-ideas/validate-whether-user-is-signed-in-to-arcgis/idi-p/1479403</link>
      <description>&lt;P&gt;When working with data and layers from ArcGIS Portal, users must be signed in to create new versions, perform edits, and post new changes. Given that each user has a specific role within the organization, it is crucial to ensure the correct user is signed in before any operations are performed. Currently, there is no straightforward Pythonic method for this validation. Implementing such a validation method would allow developers to ensure that the correct user is signed in and has the necessary permissions to edit the data even before starting an editing session.&lt;/P&gt;&lt;P&gt;This idea came to me after reading a &lt;A href="https://community.esri.com/t5/arcgis-enterprise-questions/check-if-the-user-logged-in-to-arcgis-online-or/m-p/1467338#M39497" target="_self"&gt;community question&lt;/A&gt;. In response, I suggested a workaround using the role value returned from the&lt;FONT color="#FF6600"&gt;&lt;EM&gt;&amp;nbsp;arcpy.GetPortalInfo&lt;/EM&gt;&lt;/FONT&gt; function.&lt;/P&gt;&lt;P&gt;My suggested idea is to add the username as a key in the output dictionary of GetPortalInfo. This way, developers can build tools that works only if a user is signed-in.&lt;/P&gt;&lt;P&gt;Another suggested method is to retrieve the user information from the &lt;EM&gt;&lt;FONT color="#FF6600"&gt;ArcGISProject&lt;/FONT&gt; &lt;/EM&gt;object in the &lt;EM&gt;&lt;FONT color="#FF6600"&gt;arcpy.mp module&lt;/FONT&gt;&lt;/EM&gt;. For example:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcpy.mp import ArcGISProject

my_project = ArcGISProject('current')
#option1
current_user:str = my_project.loggedUser 
#option2
condition: bool = my_project.isUserLogged&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 11:05:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-ideas/validate-whether-user-is-signed-in-to-arcgis/idi-p/1479403</guid>
      <dc:creator>Ofir_Mazor</dc:creator>
      <dc:date>2024-05-28T11:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Validate whether user is signed-in to ArcGIS Online\Portal with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-ideas/validate-whether-user-is-signed-in-to-arcgis/idc-p/1479428#M3810</link>
      <description>&lt;P&gt;I would take a look at this page that details some ways you can check to see if appropriate licensing / extensions are available without needing to check user information.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/accessing-licenses-and-extensions-in-python.htm" target="_self"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/accessing-licenses-and-extensions-in-python.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you really want to work with the User info for ArcGIS Online / Portal, you could also use the ArcGIS API for Python:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/" target="_self"&gt;https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;More specifically, something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

gis = GIS("home")
print("Logged in as: " + gis.properties.user.username)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 11:44:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-ideas/validate-whether-user-is-signed-in-to-arcgis/idc-p/1479428#M3810</guid>
      <dc:creator>Matthew_Muehlhauser</dc:creator>
      <dc:date>2024-05-28T11:44:49Z</dc:date>
    </item>
  </channel>
</rss>

