<?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 Re: A Python Web Tool is unable to access a hosted feature service in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220233#M16970</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forgot to mention that I've set up Portal's log level to 'info', but there is no information about the execution of my tool. I've also checked Srever's log messages and there is only the error that I've mensioned above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="485019" alt="ArcGIS Server log" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/485019_server-log-message.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Update: &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I thought setting up a log level on a Portal affects also a federated server... My bad.&lt;/P&gt;&lt;P&gt;Now I have set the server's log level to "debug" and I figured out that the job is submitted with a valid access token but then the request to the service is anonymous:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;DEBUG	13 mar 2020, 13:11:13	A request was made for service 'Hosted/&amp;lt;service name&amp;gt;.MapServer' but it did not have adequate credentials.	Admin
DEBUG	13 mar 2020, 13:11:13	Exception in authorize Token Required	Server
DEBUG	13 mar 2020, 13:11:13	Computed privilege for user = ACCESS	Admin
FINE	13 mar 2020, 13:11:13	HTTP Referer: Not Available	Server
INFO	13 mar 2020, 13:11:13	Request user: Anonymous user, Service: Hosted/&amp;lt;service name&amp;gt;/FeatureServer	Rest
DEBUG	13 mar 2020, 13:11:13	ARCGIS_PORTAL_TOKEN Authentication, Token is not available in the request, request is treated as anonymous	Server‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my question is: How to set the authentication in my script tool to pass currently logged user's token to external requests?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 10:44:39 GMT</pubDate>
    <dc:creator>andk</dc:creator>
    <dc:date>2021-12-11T10:44:39Z</dc:date>
    <item>
      <title>A Python Web Tool is unable to access a hosted feature service</title>
      <link>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220231#M16968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have created a simple script tool that should get one parameter (a feature class) and print some unique values from a single field. The Python code looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;get_species&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;observationFeatureClass&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; field&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; query&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;observationFeatureClass&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;field&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; query&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; species&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; sorted&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;s&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; s &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; species&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

ofc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
fld &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"gatunek"&lt;/SPAN&gt;
qry &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"kategoria = 'inwazyjna'"&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; s &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; enumerate&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;get_species&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ofc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fld&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; qry&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; start&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;f&lt;SPAN class="string token"&gt;"Gatunek nr {i}: {s}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If I run this tool straight from the ArcGIS Pro, providing a hosted feature service as a parameter, everything works well. But, when I publish the result as a Web Tool on our portal, it is unable to access the service and it returns: "RuntimeError: cannot open &amp;lt;Hosted Feature Service URL here&amp;gt;".&lt;/P&gt;&lt;P&gt;Previously, we had&amp;nbsp;a problem with accessing protected resources from a custom print service and it was resolved by applying a patch, but this tool fails regardless of the service permissions.&lt;/P&gt;&lt;P&gt;We work with ArcGIS Pro 2.5 and ArcGIS Enterprise 10.7.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:44:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220231#M16968</guid>
      <dc:creator>andk</dc:creator>
      <dc:date>2021-12-11T10:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: A Python Web Tool is unable to access a hosted feature service</title>
      <link>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220232#M16969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe check out the portal logs and see what is happening- &lt;A class="link-titled" href="https://enterprise.arcgis.com/en/portal/latest/administer/windows/about-portal-logs.htm" title="https://enterprise.arcgis.com/en/portal/latest/administer/windows/about-portal-logs.htm"&gt;About portal logs—Portal for ArcGIS (10.8) | Documentation for ArcGIS Enterprise&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Mar 2020 11:21:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220232#M16969</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-03-13T11:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: A Python Web Tool is unable to access a hosted feature service</title>
      <link>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220233#M16970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forgot to mention that I've set up Portal's log level to 'info', but there is no information about the execution of my tool. I've also checked Srever's log messages and there is only the error that I've mensioned above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="485019" alt="ArcGIS Server log" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/485019_server-log-message.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Update: &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I thought setting up a log level on a Portal affects also a federated server... My bad.&lt;/P&gt;&lt;P&gt;Now I have set the server's log level to "debug" and I figured out that the job is submitted with a valid access token but then the request to the service is anonymous:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;DEBUG	13 mar 2020, 13:11:13	A request was made for service 'Hosted/&amp;lt;service name&amp;gt;.MapServer' but it did not have adequate credentials.	Admin
DEBUG	13 mar 2020, 13:11:13	Exception in authorize Token Required	Server
DEBUG	13 mar 2020, 13:11:13	Computed privilege for user = ACCESS	Admin
FINE	13 mar 2020, 13:11:13	HTTP Referer: Not Available	Server
INFO	13 mar 2020, 13:11:13	Request user: Anonymous user, Service: Hosted/&amp;lt;service name&amp;gt;/FeatureServer	Rest
DEBUG	13 mar 2020, 13:11:13	ARCGIS_PORTAL_TOKEN Authentication, Token is not available in the request, request is treated as anonymous	Server‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my question is: How to set the authentication in my script tool to pass currently logged user's token to external requests?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:44:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220233#M16970</guid>
      <dc:creator>andk</dc:creator>
      <dc:date>2021-12-11T10:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: A Python Web Tool is unable to access a hosted feature service</title>
      <link>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220234#M16971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think the process would be for the requestor to hit the token generator for your organizations portal and get their token.&amp;nbsp; It won't get the currently logged in user on the server side, if I am understanding you correctly.&amp;nbsp; If the requestor token request is successful, they can make the request to your processing service by appending the token onto the end of the request url.&amp;nbsp; There are a few examples of getting a token floating around, this is how I do it.&amp;nbsp; svc would be your service name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; requests

&lt;SPAN class="comment token"&gt;# ---------------------------------------------------------------------------&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;getToken&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;port&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; expiration&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; server&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;try&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
       &lt;SPAN class="comment token"&gt;# Create dictionary of credentials&lt;/SPAN&gt;
       query_dict &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
                    &lt;SPAN class="string token"&gt;'username'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; username&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
                    &lt;SPAN class="string token"&gt;'password'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; password&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
                    &lt;SPAN class="string token"&gt;'expiration'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;60&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
                    &lt;SPAN class="string token"&gt;'client'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'requestip'&lt;/SPAN&gt;
                &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

       url &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"https://{}:{}/arcgis/admin/generateToken?f=json"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;server&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; port&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
       token &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; requests&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;post&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;url&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; query_dict&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;json&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

       &lt;SPAN class="comment token"&gt;# If token cannot be generated&lt;/SPAN&gt;
       &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"token"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; token&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
           &lt;SPAN class="keyword token"&gt;raise&lt;/SPAN&gt; ValueError&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Did not return a token: {}'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;token&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
       &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
           &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; token&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'token'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

       &lt;SPAN class="keyword token"&gt;except&lt;/SPAN&gt; requests&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;exceptions &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; e&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
           &lt;SPAN class="keyword token"&gt;raise&lt;/SPAN&gt; Exception&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Could not connect to machine {} on port {}\n{}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;server&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; port&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; e&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

       &lt;SPAN class="keyword token"&gt;except&lt;/SPAN&gt; RuntimeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
           logger&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;info&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Runtime Error: {}'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;traceback&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The return token will get appended to the request url string like this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;service_url &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"{}/services/{}?token={}&amp;amp;f=json"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;url&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; svc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; token&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍

result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; requests&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;post&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;service_url&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;json&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps and maybe someone more versed in this area can assist.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:44:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220234#M16971</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T10:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: A Python Web Tool is unable to access a hosted feature service</title>
      <link>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220235#M16972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, but the tool is to be published on the portal. Users will run it against various feature services (from the portal's analysis tab in the web map view). They should be able to choose a feature class from the portal's resources. The tool cannot require providing credentials every time when someone wants to use it.&lt;/P&gt;&lt;P&gt;Documentation says: "Most Python script tools that execute successfully on your computer will publish and execute successfully as a web tool—you do not have to modify your script in any way." (&lt;A href="https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/share-analysis/authoring-web-tools-with-python-scripts.htm"&gt;source&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;Maybe I have missed something, but in ArcGIS Pro I am logged in to the portal and I am able to simply run arcpy.da.SearchCursor(&amp;lt;service url&amp;gt;, ...) either from the python console or as a script tool. Authenticaton is handled in the background. The same tool, published and executed from the portal's interface, has a problem with accessing resources&amp;nbsp;selected by an authenticated user.&lt;/P&gt;&lt;DIV style="position: absolute; left: 133px; top: 186.889px;"&gt;&lt;DIV class="gtx-trans-icon"&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV style="position: absolute; left: 31px; top: 190.667px;"&gt;&lt;DIV class="gtx-trans-icon"&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Mar 2020 17:59:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220235#M16972</guid>
      <dc:creator>andk</dc:creator>
      <dc:date>2020-03-14T17:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: A Python Web Tool is unable to access a hosted feature service</title>
      <link>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220236#M16973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah gotcha.&amp;nbsp; Wasn't quite sure how you were hitting the service and saw 'web' in the title so I thought of webmap/http access, which if the service is not publicly shared, the user gains access to the service through requesting/providing tokens every time they use the tool.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I interpret that documentation statement as referring to only the tools code. There is still a lot of other things that needs to be done in order for the tools to be used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... Is it set up as a secured service?&amp;nbsp; Was it shared with a group of authorized users?&amp;nbsp; Halfway down: &lt;A class="link-titled" href="https://enterprise.arcgis.com/en/portal/latest/use/connect-secured-services.htm" title="https://enterprise.arcgis.com/en/portal/latest/use/connect-secured-services.htm"&gt;Connect to secure services—Portal for ArcGIS | Documentation for ArcGIS Enterprise&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Mar 2020 22:19:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220236#M16973</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-03-14T22:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: A Python Web Tool is unable to access a hosted feature service</title>
      <link>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220237#M16974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, it is secured. Both, the tool and the feature service are owned by me. I have full access to them. I am publishing and running this tool with the same account. Unfortunately, even if I allow&amp;nbsp;public access to the feature service, the error keeps occuring.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2020 11:25:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/220237#M16974</guid>
      <dc:creator>andk</dc:creator>
      <dc:date>2020-03-17T11:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: A Python Web Tool is unable to access a hosted feature service</title>
      <link>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/1210161#M65503</link>
      <description>&lt;P&gt;andk, Was there a resolution to your issue? I am experiencing the same thing. .pyt works locally but not as a web tool.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Sep 2022 23:20:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/a-python-web-tool-is-unable-to-access-a-hosted/m-p/1210161#M65503</guid>
      <dc:creator>LukeHenderson1</dc:creator>
      <dc:date>2022-09-06T23:20:46Z</dc:date>
    </item>
  </channel>
</rss>

