<?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: Access secured Feature Service  in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/access-secured-feature-service/m-p/96592#M3727</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/329627"&gt;Meghan Kulkarni&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you by chance able to provide the actual code you are using when running? You can of course use fake usernames/passwords/URLs, but I just wanted to ensure that there was no syntax issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Beyond that, I also wanted to ask if you are executing the code on the same machine that you are able to access the feature service URL from in a web browser. If not, then is the machine that you are executing from connected within the same network as the ArcGIS Server? Or do you know if it has access to that server?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Jan 2019 21:52:38 GMT</pubDate>
    <dc:creator>DanielCota1</dc:creator>
    <dc:date>2019-01-03T21:52:38Z</dc:date>
    <item>
      <title>Access secured Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/access-secured-feature-service/m-p/96591#M3726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using below code to access FeatureService published using ArcGIS Server. REST endpoint is access protected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-weight: bold;"&gt;import &lt;/SPAN&gt;urllib, httplib
&lt;SPAN style="font-weight: bold;"&gt;def &lt;/SPAN&gt;&lt;SPAN style="color: #990000; font-weight: bold;"&gt;getToken&lt;/SPAN&gt;(&lt;SPAN&gt;username&lt;/SPAN&gt;, &lt;SPAN&gt;password&lt;/SPAN&gt;, &lt;SPAN&gt;serverName&lt;/SPAN&gt;, &lt;SPAN&gt;serverPort&lt;/SPAN&gt;)&lt;SPAN style="font-weight: bold;"&gt;:
&lt;/SPAN&gt;&lt;SPAN style="font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #999988;"&gt;&lt;SPAN&gt;# Token URL is typically &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fserver%5B%3Aport%5D%2Farcgis%2Fadmin%2FgenerateToken" target="_blank"&gt;http://server[:port]/arcgis/admin/generateToken&lt;/A&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #999988;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;tokenURL &lt;SPAN style="font-weight: bold;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;"/arcgis/tokens/generateToken"&lt;/SPAN&gt;&lt;SPAN style="color: #dd1144;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #dd1144;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #dd1144;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #999988;"&gt;# URL-encode the token parameters:-
&lt;/SPAN&gt;&lt;SPAN style="color: #999988;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;params &lt;SPAN style="font-weight: bold;"&gt;= &lt;/SPAN&gt;urllib.urlencode({&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;'username'&lt;/SPAN&gt;&lt;SPAN style="font-weight: bold;"&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;username&lt;/SPAN&gt;, &lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;'password'&lt;/SPAN&gt;&lt;SPAN style="font-weight: bold;"&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;password&lt;/SPAN&gt;, &lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;'client'&lt;/SPAN&gt;&lt;SPAN style="font-weight: bold;"&gt;: &lt;/SPAN&gt;&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;'requestip'&lt;/SPAN&gt;, &lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;'f'&lt;/SPAN&gt;&lt;SPAN style="font-weight: bold;"&gt;: &lt;/SPAN&gt;&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;'json'&lt;/SPAN&gt;})
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; headers &lt;SPAN style="font-weight: bold;"&gt;= &lt;/SPAN&gt;{&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;"Content-type"&lt;/SPAN&gt;&lt;SPAN style="font-weight: bold;"&gt;: &lt;/SPAN&gt;&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;"application/x-www-form-urlencoded"&lt;/SPAN&gt;, &lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;"Accept"&lt;/SPAN&gt;&lt;SPAN style="font-weight: bold;"&gt;: &lt;/SPAN&gt;&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;"text/plain"&lt;/SPAN&gt;}
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #999988;"&gt;# Connect to URL and post parameters
&lt;/SPAN&gt;&lt;SPAN style="color: #999988;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;httpConn &lt;SPAN style="font-weight: bold;"&gt;= &lt;/SPAN&gt;httplib.HTTPConnection(&lt;SPAN&gt;serverName&lt;/SPAN&gt;, &lt;SPAN&gt;serverPort&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp; httpConn.request(&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;"POST"&lt;/SPAN&gt;, tokenURL, params, headers)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #999988;"&gt;# Read response
&lt;/SPAN&gt;&lt;SPAN style="color: #999988;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;response &lt;SPAN style="font-weight: bold;"&gt;= &lt;/SPAN&gt;httpConn.getresponse()
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: bold;"&gt;if &lt;/SPAN&gt;(response.status &lt;SPAN style="font-weight: bold;"&gt;!= &lt;/SPAN&gt;&lt;SPAN style="color: #009999;"&gt;200&lt;/SPAN&gt;)&lt;SPAN style="font-weight: bold;"&gt;:
&lt;/SPAN&gt;&lt;SPAN style="font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;httpConn.close()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: bold;"&gt;print &lt;/SPAN&gt;&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;"Error while fetch tokens from admin URL. Please check the URL and try again."&lt;/SPAN&gt;&lt;SPAN style="color: #dd1144;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #dd1144;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-weight: bold;"&gt;return
&lt;/SPAN&gt;&lt;SPAN style="font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&lt;/SPAN&gt;&lt;SPAN style="font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;data &lt;SPAN style="font-weight: bold;"&gt;= &lt;/SPAN&gt;response.read()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpConn.close()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #999988;"&gt;# Extract the token from it
&lt;/SPAN&gt;&lt;SPAN style="color: #999988;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;token &lt;SPAN style="font-weight: bold;"&gt;= &lt;/SPAN&gt;json.loads(data)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: bold;"&gt;return &lt;/SPAN&gt;token[&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;'token'&lt;/SPAN&gt;]

&lt;SPAN style="font-weight: bold;"&gt;if &lt;/SPAN&gt;__name__ &lt;SPAN style="font-weight: bold;"&gt;== &lt;/SPAN&gt;&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;'__main__'&lt;/SPAN&gt;&lt;SPAN style="font-weight: bold;"&gt;:
&lt;/SPAN&gt;&lt;SPAN style="font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;token &lt;SPAN style="font-weight: bold;"&gt;= &lt;/SPAN&gt;getToken(&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;'&amp;lt;username&amp;gt;'&lt;/SPAN&gt;,&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;'&amp;lt;password&amp;gt;'&lt;/SPAN&gt;,&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;'&amp;lt;host&amp;gt;'&lt;/SPAN&gt;,&lt;SPAN style="color: #dd1144; background-color: #f7e7f1;"&gt;'6443'&lt;/SPAN&gt;)
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: bold;"&gt;print &lt;/SPAN&gt;token&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get below error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;socket.error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm able to access this Feature Service if I put this URL in a browser and enter the username, password.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I missing something in the above code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Best,&lt;/P&gt;&lt;P&gt;Meghan Kulkarni&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:04:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/access-secured-feature-service/m-p/96591#M3726</guid>
      <dc:creator>MeghanKulkarni</dc:creator>
      <dc:date>2021-12-11T06:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Access secured Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/access-secured-feature-service/m-p/96592#M3727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/329627"&gt;Meghan Kulkarni&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you by chance able to provide the actual code you are using when running? You can of course use fake usernames/passwords/URLs, but I just wanted to ensure that there was no syntax issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Beyond that, I also wanted to ask if you are executing the code on the same machine that you are able to access the feature service URL from in a web browser. If not, then is the machine that you are executing from connected within the same network as the ArcGIS Server? Or do you know if it has access to that server?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jan 2019 21:52:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/access-secured-feature-service/m-p/96592#M3727</guid>
      <dc:creator>DanielCota1</dc:creator>
      <dc:date>2019-01-03T21:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Access secured Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/access-secured-feature-service/m-p/96593#M3728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got that working Dan. Thanks for heads up.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jan 2019 20:24:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/access-secured-feature-service/m-p/96593#M3728</guid>
      <dc:creator>MeghanKulkarni</dc:creator>
      <dc:date>2019-01-04T20:24:57Z</dc:date>
    </item>
  </channel>
</rss>

