<?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: how to get token to access a map service or feature service? in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-get-token-to-access-a-map-service-or/m-p/601521#M2861</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is a link to some code in this blog article that gets a token: &lt;A href="https://blogs.esri.com/esri/arcgis/2014/10/07/using-python-to-push-updates-to-a-hosted-feature-service-from-an-external-source/" title="https://blogs.esri.com/esri/arcgis/2014/10/07/using-python-to-push-updates-to-a-hosted-feature-service-from-an-external-source/" rel="nofollow noopener noreferrer" target="_blank"&gt;Using Python to push updates to a hosted feature service from an external source | ArcGIS Blog&lt;/A&gt;.&amp;nbsp; Here are the basic steps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import urllib
import urllib2
import json

# Credentials and feature service information
username = '&amp;lt;username&amp;gt;'
password = '&amp;lt;password&amp;gt;'
URL = "&amp;lt;the services url you want to connect to&amp;gt;"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# obtain a token
referer = "&lt;A href="http://www.arcgis.com/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.arcgis.com/&lt;/A&gt;"
query_dict = { 'username': username, 'password': password, 'referer': referer }

query_string = urllib.urlencode(query_dict)
url = "&lt;A href="https://www.arcgis.com/sharing/rest/generateToken" rel="nofollow noopener noreferrer" target="_blank"&gt;https://www.arcgis.com/sharing/rest/generateToken&lt;/A&gt;"
token = json.loads(urllib.urlopen(url + "?f=json", query_string).read())

if "token" not in token:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(token['error'])
&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.exit(1)

query_dict = { "f": "json", "token": token['token'] }

# query your services url
jsonResponse = urllib.urlopen(URL, urllib.urlencode(query_dict))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:47:25 GMT</pubDate>
    <dc:creator>RandyBurton</dc:creator>
    <dc:date>2021-12-12T01:47:25Z</dc:date>
    <item>
      <title>how to get token to access a map service or feature service?</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-get-token-to-access-a-map-service-or/m-p/601520#M2860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I would like to access mao services for example this one: &lt;A href="http://earthobs1.arcgis.com/arcgis/rest/services/Live_Stream_Gauges/MapServer/" title="http://earthobs1.arcgis.com/arcgis/rest/services/Live_Stream_Gauges/MapServer/"&gt;http://earthobs1.arcgis.com/arcgis/rest/services/Live_Stream_Gauges/MapServer/&lt;/A&gt; , if I type the url in browser, it redirects me to the arcgis online login, then I can access the map server. But if I want to access the map server using python code with the REST API, how do I get the token? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also noticed that there are many ways to get the token, like using '&lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Oauth2.0 token' or 'generateToken'. I just don't know what I should use and what exactly is the url I need to use to get the token in this case. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Jun 2016 00:41:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-get-token-to-access-a-map-service-or/m-p/601520#M2860</guid>
      <dc:creator>BoYan</dc:creator>
      <dc:date>2016-06-25T00:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to get token to access a map service or feature service?</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-get-token-to-access-a-map-service-or/m-p/601521#M2861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is a link to some code in this blog article that gets a token: &lt;A href="https://blogs.esri.com/esri/arcgis/2014/10/07/using-python-to-push-updates-to-a-hosted-feature-service-from-an-external-source/" title="https://blogs.esri.com/esri/arcgis/2014/10/07/using-python-to-push-updates-to-a-hosted-feature-service-from-an-external-source/" rel="nofollow noopener noreferrer" target="_blank"&gt;Using Python to push updates to a hosted feature service from an external source | ArcGIS Blog&lt;/A&gt;.&amp;nbsp; Here are the basic steps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import urllib
import urllib2
import json

# Credentials and feature service information
username = '&amp;lt;username&amp;gt;'
password = '&amp;lt;password&amp;gt;'
URL = "&amp;lt;the services url you want to connect to&amp;gt;"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# obtain a token
referer = "&lt;A href="http://www.arcgis.com/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.arcgis.com/&lt;/A&gt;"
query_dict = { 'username': username, 'password': password, 'referer': referer }

query_string = urllib.urlencode(query_dict)
url = "&lt;A href="https://www.arcgis.com/sharing/rest/generateToken" rel="nofollow noopener noreferrer" target="_blank"&gt;https://www.arcgis.com/sharing/rest/generateToken&lt;/A&gt;"
token = json.loads(urllib.urlopen(url + "?f=json", query_string).read())

if "token" not in token:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(token['error'])
&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.exit(1)

query_dict = { "f": "json", "token": token['token'] }

# query your services url
jsonResponse = urllib.urlopen(URL, urllib.urlencode(query_dict))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:47:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-get-token-to-access-a-map-service-or/m-p/601521#M2861</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-12T01:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to get token to access a map service or feature service?</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-get-token-to-access-a-map-service-or/m-p/601522#M2862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks, I haven't tried your approach yet, but I figured that I can create an application in my developer account and use the app id and secret to get token for the rest api&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jun 2016 23:59:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-get-token-to-access-a-map-service-or/m-p/601522#M2862</guid>
      <dc:creator>BoYan</dc:creator>
      <dc:date>2016-06-30T23:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to get token to access a map service or feature service?</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-get-token-to-access-a-map-service-or/m-p/601523#M2863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-left: 0in;"&gt;How to enable token for a particular map service?&lt;/P&gt;&lt;P style="margin-left: 0in;"&gt;&lt;/P&gt;&lt;P style="margin-left: 0in;"&gt;&lt;/P&gt;&lt;P style="margin-left: 0in;"&gt;&lt;/P&gt;&lt;P style="margin-left: 0in;"&gt;&lt;IMG __jive_id="506435" alt="" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/506435_Clip_79.jpg" /&gt;&lt;/P&gt;&lt;P style="margin-left: 0in;"&gt;&lt;/P&gt;&lt;P style="margin-left: 0in;"&gt;&lt;IMG alt="" class="jive-emoji jive-image image-2 j-img-original" src="https://community.esri.com/legacyfs/online/506436_Clip_80.jpg" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Sep 2020 16:57:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-get-token-to-access-a-map-service-or/m-p/601523#M2863</guid>
      <dc:creator>JamalNUMAN</dc:creator>
      <dc:date>2020-09-04T16:57:48Z</dc:date>
    </item>
  </channel>
</rss>

