<?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: example for using token for exporting secured feature service to feature class in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/example-for-using-token-for-exporting-secured/m-p/516238#M40507</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the code Kevin. Unfortunately, I'm still having problems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I use your token code, the token is being generated but I still can't access the feature service. If I message the URL + Query I get the message below showing the token (URL has been partially rewritten):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://FishAndWildlifeURL.gov/arcgis/rest/services/Wildlife/WildlifePtObs/FeatureServer/0/query?where=1=1&amp;amp;outFields=&amp;amp;returnGeometry=true&amp;amp;f=json&amp;amp;token=AgPfmAcCANy32hXn9QGsOGV2K0ObDiqw8ZQ0tBIV3Ao1HAOEJG-MIJtZpdWHBkZ2Y9eab_1oGdwqyNe9jaoWkQ0W1GEHIO4JBvbOnVZmmS4" rel="nofollow" target="_blank"&gt;https://FishAndWildlifeURL.gov/arcgis/rest/services/Wildlife/WildlifePtObs/FeatureServer/0/query?where=1=1&amp;amp;outFields=&amp;amp;returnGeometry=true&amp;amp;f=json&amp;amp;token=AgPfmAcCANy32hXn9QGsOGV2K0ObDiqw8ZQ0tBIV3Ao1HAOEJG-MIJtZpdWHBkZ2Y9eab_1oGdwqyNe9jaoWkQ0W1GEHIO4JBvbOnVZmmS4&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But then I get the following errors:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\data\Projects\WildlifeObs_DataExportTool.py", line 72, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fs.load(fsURL)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\arcobjects\arcobjects.py", line 173, in load&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return convertArcObjectToPythonObject(self._arc_object.Load(*gp_fixargs(args)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RuntimeError: RecordSetObject: Cannot open table for Load&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are a few things that are different about our configuration that may be the problem?:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-it's a https address instead of http&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;-there may be a problem with the web adapter because I have to use a port# in the tokenurl (tokenUrl = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://FishAndWildlifeURL.gov:6443/arcgis/tokens/" rel="nofollow" target="_blank"&gt;https://FishAndWildlifeURL.gov:6443/arcgis/tokens/&lt;/A&gt;&lt;SPAN&gt;")&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-the machine I'm running the script on is behind a firewall that is different from where the feature service is stored&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas? Keep in mind that if I set the token to blank and log into the secured REST endpoint in my web browser I can run the code and get a feature class produced, so it still a problem with security and not the conversion of feat service to feat class.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 Nov 2013 21:05:26 GMT</pubDate>
    <dc:creator>tregchristopher1</dc:creator>
    <dc:date>2013-11-06T21:05:26Z</dc:date>
    <item>
      <title>example for using token for exporting secured feature service to feature class</title>
      <link>https://community.esri.com/t5/python-questions/example-for-using-token-for-exporting-secured/m-p/516236#M40505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'd like to use the ESRI blog example for exporting a feature service to a feature class using Python. This simple example is found at the bottom of:&lt;/SPAN&gt;&lt;A href="http://blogs.esri.com/esri/arcgis/2013/10/10/quick-tips-consuming-feature-services-with-geoprocessing/"&gt;http://blogs.esri.com/esri/arcgis/2013/10/10/quick-tips-consuming-feature-services-with-geoprocessing/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've been able to get this to work for non-secured services or for a secured service where I am already logged in to the REST endpoint through my browser. However, I can't figure out the format for replacing the empty token variable used in the example with my actual ArcGIS Server credentials that I would use if I viewed the feature service in a browser.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any help you can provide.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Nov 2013 21:35:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/example-for-using-token-for-exporting-secured/m-p/516236#M40505</guid>
      <dc:creator>tregchristopher1</dc:creator>
      <dc:date>2013-11-05T21:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: example for using token for exporting secured feature service to feature class</title>
      <link>https://community.esri.com/t5/python-questions/example-for-using-token-for-exporting-secured/m-p/516237#M40506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can use this code to obtain a token....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import json, urllib, urllib2

USERNAME = "____"
PASSWORD = "_____"
REFER = "http://www.arcgis.com"

def urlopen(url, data=None):
&amp;nbsp;&amp;nbsp;&amp;nbsp; referer = "http://arcgis.com/arcgis/rest"
&amp;nbsp;&amp;nbsp;&amp;nbsp; req = urllib2.Request(url)
&amp;nbsp;&amp;nbsp;&amp;nbsp; req.add_header('Referer', referer)

&amp;nbsp;&amp;nbsp;&amp;nbsp; if data:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; response = urllib2.urlopen(req, data)
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; response = urllib2.urlopen(req)

&amp;nbsp;&amp;nbsp;&amp;nbsp; return response


def gentoken(username, password, referer, expiration=60):
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Re-usable function to get a token&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; query_dict = {'username': username,
&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; 'password': password,
&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; 'expiration': str(expiration),
&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; 'client': 'referer',
&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; 'referer': referer,
&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; 'f': 'json'}&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; query_string = urllib.urlencode(query_dict)
&amp;nbsp;&amp;nbsp;&amp;nbsp; tokenUrl = "https://www.arcgis.com/sharing/rest/generateToken"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; tokenResponse = urllib.urlopen(tokenUrl, urllib.urlencode(query_dict))&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; token = json.loads(tokenResponse.read())
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; if "token" not in token:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print token['messages']
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit()
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Return the token to the function which called for it
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return token['token']
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
token = gentoken(USERNAME, PASSWORD, REFER)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:32:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/example-for-using-token-for-exporting-secured/m-p/516237#M40506</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2021-12-11T22:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: example for using token for exporting secured feature service to feature class</title>
      <link>https://community.esri.com/t5/python-questions/example-for-using-token-for-exporting-secured/m-p/516238#M40507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the code Kevin. Unfortunately, I'm still having problems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I use your token code, the token is being generated but I still can't access the feature service. If I message the URL + Query I get the message below showing the token (URL has been partially rewritten):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://FishAndWildlifeURL.gov/arcgis/rest/services/Wildlife/WildlifePtObs/FeatureServer/0/query?where=1=1&amp;amp;outFields=&amp;amp;returnGeometry=true&amp;amp;f=json&amp;amp;token=AgPfmAcCANy32hXn9QGsOGV2K0ObDiqw8ZQ0tBIV3Ao1HAOEJG-MIJtZpdWHBkZ2Y9eab_1oGdwqyNe9jaoWkQ0W1GEHIO4JBvbOnVZmmS4" rel="nofollow" target="_blank"&gt;https://FishAndWildlifeURL.gov/arcgis/rest/services/Wildlife/WildlifePtObs/FeatureServer/0/query?where=1=1&amp;amp;outFields=&amp;amp;returnGeometry=true&amp;amp;f=json&amp;amp;token=AgPfmAcCANy32hXn9QGsOGV2K0ObDiqw8ZQ0tBIV3Ao1HAOEJG-MIJtZpdWHBkZ2Y9eab_1oGdwqyNe9jaoWkQ0W1GEHIO4JBvbOnVZmmS4&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But then I get the following errors:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\data\Projects\WildlifeObs_DataExportTool.py", line 72, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fs.load(fsURL)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\arcobjects\arcobjects.py", line 173, in load&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return convertArcObjectToPythonObject(self._arc_object.Load(*gp_fixargs(args)))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RuntimeError: RecordSetObject: Cannot open table for Load&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are a few things that are different about our configuration that may be the problem?:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-it's a https address instead of http&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;-there may be a problem with the web adapter because I have to use a port# in the tokenurl (tokenUrl = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://FishAndWildlifeURL.gov:6443/arcgis/tokens/" rel="nofollow" target="_blank"&gt;https://FishAndWildlifeURL.gov:6443/arcgis/tokens/&lt;/A&gt;&lt;SPAN&gt;")&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-the machine I'm running the script on is behind a firewall that is different from where the feature service is stored&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas? Keep in mind that if I set the token to blank and log into the secured REST endpoint in my web browser I can run the code and get a feature class produced, so it still a problem with security and not the conversion of feat service to feat class.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Nov 2013 21:05:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/example-for-using-token-for-exporting-secured/m-p/516238#M40507</guid>
      <dc:creator>tregchristopher1</dc:creator>
      <dc:date>2013-11-06T21:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: example for using token for exporting secured feature service to feature class</title>
      <link>https://community.esri.com/t5/python-questions/example-for-using-token-for-exporting-secured/m-p/516239#M40508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;&lt;SPAN&gt;OK, I finally got a solution to work (posted below). The code is different from what Kevin posted above but the key to making this work was to change the value for the SERVER variable (or REFER in Kevin's example) from something like "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://myGovWebsite.gov" rel="nofollow" target="_blank"&gt;https://myGovWebsite.gov&lt;/A&gt;&lt;SPAN&gt;" to just "myGovWebsite.gov" (no http prefix). Sorry about the missing indents for the Python code below.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy, json, urllib, httplib&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;USERNAME = "____"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PASSWORD = "_____"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;SERVERNAME = "FishAndWildlifeURL.gov"#omit the "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://" rel="nofollow" target="_blank"&gt;https://&lt;/A&gt;&lt;SPAN&gt;" prefix for this to work&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;PORT = "6443"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def getToken(username, password, serverName, serverPort):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt; tokenURL = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://FishAndWildlifeURL:6443/arcgis/admin/generateToken" rel="nofollow" target="_blank"&gt;https://FishAndWildlifeURL:6443/arcgis/admin/generateToken&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; params = urllib.urlencode({'username': username, 'password': password,'client': 'requestip', 'f': 'json'})&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; # Connect to URL and post parameters&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; httpConn = httplib.HTTPSConnection(serverName, serverPort)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; httpConn.request("POST", tokenURL, params, headers)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; # Read response&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; response = httpConn.getresponse()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; print response.status&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if (response.status != 200):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; httpConn.close()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; print "Error while fetching tokens from admin URL. Please check the URL and try again."&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; data = response.read()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; httpConn.close()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; # Check that data returned is not an error object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if not assertJsonSuccess(data): &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; # Extract the token from it&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; token = json.loads(data) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return token['token']&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;###End getToken function&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# A function that checks that the input JSON object is not an error object. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def assertJsonSuccess(data):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; obj = json.loads(data)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if 'status' in obj and obj['status'] == "error":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; print "Error: JSON object returns an error. " + str(obj)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return False&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return True&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;### End jsonSuccess function&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Query for service, with URL, where clause, fields and token&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;baseURL= "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://FishAndWildlifeURL:6443/arcgis/rest/services/myFolder/myObs/FeatureServer/0/query" rel="nofollow" target="_blank"&gt;https://FishAndWildlifeURL:6443/arcgis/rest/services/myFolder/myObs/FeatureServer/0/query&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where = '1=1'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fields = '*'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;token = getToken(USERNAME, PASSWORD, SERVERNAME, PORT)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;query = "?where={}&amp;amp;outFields={}&amp;amp;returnGeometry=true&amp;amp;f=json&amp;amp;token={}".format(where, fields, token)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fsURL = baseURL + query&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fs = arcpy.FeatureSet()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fs.load(fsURL) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CopyFeatures_management(fs, r"C:\Default.gdb\temp_obs")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 19:40:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/example-for-using-token-for-exporting-secured/m-p/516239#M40508</guid>
      <dc:creator>tregchristopher1</dc:creator>
      <dc:date>2013-11-25T19:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: example for using token for exporting secured feature service to feature class</title>
      <link>https://community.esri.com/t5/python-questions/example-for-using-token-for-exporting-secured/m-p/516240#M40509</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Excellent work!&amp;nbsp; This is just what I needed!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some modifications I had to make to Treg's code in order to get this to work, since it seems Python 3.x handles some things differently:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had to import http.client instead of httplib&lt;/P&gt;&lt;P&gt;I had to use 'params = urllib.parse.urlencode(...' instead of 'params = urllib.urlencode(...'&lt;/P&gt;&lt;P&gt;I am using a web adaptor, so I left the PORT null, and just changed the tokenURL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other than that, this worked!&amp;nbsp; Now I just need to figure out how to push edits/additions back up to the feature service via arcpy...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jan 2019 23:27:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/example-for-using-token-for-exporting-secured/m-p/516240#M40509</guid>
      <dc:creator>MatthewWalker</dc:creator>
      <dc:date>2019-01-25T23:27:57Z</dc:date>
    </item>
  </channel>
</rss>

