<?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 Proxy server configuration and portal authentication in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/proxy-server-configuration-and-portal/m-p/1174063#M7402</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I am trying to write a stand alone python script that accesses a REST API feature service using ArcGIS Python for API.&amp;nbsp;The service is sitting in a portal of my organisation.&lt;BR /&gt;When using ArcGIS pro, I am supposed to use a Single Sign On system for an authentication to access the service that means I do not have a built-in account for the portal to use in the script.&lt;BR /&gt;I may be wrong but I understand that I need to configure a proxy server in the script by providing my own login credential to a proxy server.&lt;BR /&gt;But I am new to Python API, I don't know an appropriate way to achieve this.&lt;BR /&gt;Much appreciated if anyone could tell me some solutions.&lt;/P&gt;</description>
    <pubDate>Tue, 17 May 2022 00:15:07 GMT</pubDate>
    <dc:creator>Aнастасия88</dc:creator>
    <dc:date>2022-05-17T00:15:07Z</dc:date>
    <item>
      <title>Proxy server configuration and portal authentication</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/proxy-server-configuration-and-portal/m-p/1174063#M7402</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I am trying to write a stand alone python script that accesses a REST API feature service using ArcGIS Python for API.&amp;nbsp;The service is sitting in a portal of my organisation.&lt;BR /&gt;When using ArcGIS pro, I am supposed to use a Single Sign On system for an authentication to access the service that means I do not have a built-in account for the portal to use in the script.&lt;BR /&gt;I may be wrong but I understand that I need to configure a proxy server in the script by providing my own login credential to a proxy server.&lt;BR /&gt;But I am new to Python API, I don't know an appropriate way to achieve this.&lt;BR /&gt;Much appreciated if anyone could tell me some solutions.&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 00:15:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/proxy-server-configuration-and-portal/m-p/1174063#M7402</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2022-05-17T00:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proxy server configuration and portal authentication</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/proxy-server-configuration-and-portal/m-p/1174279#M7406</link>
      <description>&lt;P&gt;Usually I just use my username and password, it's using Active Directory for authentication but it still works with the Python API.&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
PORTAL_URL="https://myportal/portal"
PORTAL_USER="bwilson@WINDOWSDOMAIN"
PORTAL_PASSWORD="my active directory password"
gis = GIS(PORTAL_URL, PORTAL_USER, PORTAL_PASSWORD)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;It's possible to create a token in Portal and then use the token in your script. I'm sure I messed around with that a few months ago? If you go to the "portaladmin" site you can get a token with an expiration time and a URL to limit it&amp;nbsp; The URL is like &lt;A href="https://YOURPORTALNAME/portal/portaladmin" target="_blank" rel="noopener"&gt;https://YOURPORTALNAME/portal/portaladmin&lt;/A&gt;&amp;nbsp;and click "Generate Token".&lt;/P&gt;&lt;P&gt;So go generate a token, then copy the string and paste it, something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;token = "yBj8Gde3jFvLqbCWIyAG5p5fi0-lK8liEjd9JfPFD2ez2zEvoLlRnmHayZNEeqaoo98Cx0xRqiem-wLaCEKTE7KGyaXv3fRytAg7foDE8ugPdx9p7hrk-_RFPv63NwG9-i9tEjSh9snfb4xGcygM4q4FnmrNw8OM48k3GAie-UFVQaIU1Df065AHZkBTCG-xh1AOMr3FWW5vbHQw.."
gis = GIS(PORTAL_URL,api_key=token)
print(gis)
q = '*'
list_of_maps = gis.content.search(
        q, item_type='web map', outside_org=False, max_items=5000)
print("Maps found %d" % len(list_of_maps))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;on my computer this generated text like this&lt;/P&gt;&lt;P&gt;GIS @ &lt;A href="https://MYURL/portal" target="_blank" rel="noopener"&gt;https://MYURL/portal&lt;/A&gt; version:8.4&lt;BR /&gt;Maps found 50&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 18:07:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/proxy-server-configuration-and-portal/m-p/1174279#M7406</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2022-05-16T18:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proxy server configuration and portal authentication</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/proxy-server-configuration-and-portal/m-p/1174413#M7408</link>
      <description>&lt;P&gt;Thanks for your suggestion. Unfortunately, as I am not an administrator for the portal, I cannot log in the admin site to generate Token.&lt;/P&gt;&lt;P&gt;Since I do not have my own username and password for the portal, I obtained "Client ID" to use "&lt;STRONG&gt;ArcGIS Python API supports&amp;nbsp;&lt;A href="https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/what-is-oauth-2/" target="_blank"&gt;OAuth 2.0&lt;/A&gt;&amp;nbsp;as an authentication method&lt;/STRONG&gt;" (&lt;A href="https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/)" target="_blank"&gt;https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/)&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
gis = GIS("https://************/portal", client_id='*********')
print("Successfully logged in as: " + gis.properties.user.username)&lt;/LI-CODE&gt;&lt;P&gt;but this still did not success for some reasons&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2022 00:32:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/proxy-server-configuration-and-portal/m-p/1174413#M7408</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2022-05-17T00:32:07Z</dc:date>
    </item>
  </channel>
</rss>

