<?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: Help me understand tokens in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/help-me-understand-tokens/m-p/293255#M11315</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The final URL should look like this...what I was missing was defining the task after you define what type of server you're trying to access:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.domain.com/serverName/myfolder/myservice/GPServer/task?&amp;lt;token"&gt;https://www.domain.com/serverName/myfolder/myservice/typeOfServer/task?&amp;lt;token&lt;/A&gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/www.blahblahblah.org/natureServer/HabitatManagement/Habitatmanagement/GPServer/HabitatManagement?a89sd79faklj234fa087sljk34dadf878234klsd897234lksdoeroi" rel="nofollow" target="_blank"&gt;https://www.blahblahblah.org/natureServer/HabitatManagement/HabitatManagement/GPServer/HabitatManagement?a89sd79faklj234fa087sljk34dadf878234klsd897234lksdoeroi&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**Note that I am using the above URLs with a web adapter installed so I can access my services directly from my domain. If you're not using a web adapter then it'd be something more like this:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/serverName:6080/arcgis/HabitatManagement/HabitatManagement/GPServer/HabitatManagement" rel="nofollow" target="_blank"&gt;https://natureServer:6080/arcgis/HabitatManagement/HabitatManagement/GPServer/HabitatManagement&lt;/A&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;A _jive_internal="true" class="" href="https://community.esri.com/www.blahblahblah.org/natureServer/HabitatManagement/Habitatmanagement/GPServer/HabitatManagement?a89sd79faklj234fa087sljk34dadf878234klsd897234lksdoeroi" rel="nofollow" style="color: #2989c5; text-decoration: none; padding-right: calc(12px + 0.35ex);" target="_blank"&gt;a89sd79faklj234fa087sljk34dadf878234klsd897234lksdoeroi&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To illustrate this further, from your main rest services page, your folders:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="424992" alt="" class="image-4 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/424992_Capture.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I click on HabitatManagement, I get taken to my services:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="424978" alt="" class="image-2 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/424978_Capture.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I click on that service, I get taken to my tasks&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="424991" alt="" class="image-3 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/424991_Capture.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Those make up the three parts of your URL. After you append the token to end of that (don't forget the question mark!) then it should log you in automatically and give you access.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Oct 2018 15:11:43 GMT</pubDate>
    <dc:creator>MKF62</dc:creator>
    <dc:date>2018-10-22T15:11:43Z</dc:date>
    <item>
      <title>Help me understand tokens</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/help-me-understand-tokens/m-p/293252#M11312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;I'm messing around with securing my services and plan on putting in place token-based authentication for our JS API application. I'm just trying to get a handle on what tokens do and how they work. I have made a user in our ArcGIS server, assigned it the "User" role, and have set one service to only allow access by logged in users that are part of the "user" role. I went to generate a token at &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fdomain.com%2FserverName%2Ftokens" rel="nofollow" target="_blank"&gt;https://domain.com/serverName/tokens&lt;/A&gt;&lt;SPAN&gt; and filled that out to generate the token. I filled out the HTTP referer field as &lt;/SPAN&gt;&lt;A href="http://www.domain.com"&gt;www.domain.com&lt;/A&gt;&amp;nbsp;with the domain our JS API web app sits on.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, when I try to access that service via the rest endpoint with the token, I get taken to a login page. Isn't the token supposed to automatically log me in and give me access to the service? If not, how is the token doing anything different than just going to services page and hitting "Login"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is how I'm trying to access the service with the generated token:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;&lt;A href="http://gisserver.domain.com:6080/arcgis/rest/services/myfolder/myservice/MapServer?&amp;lt;token"&gt;https://www.domain.com/serverName/rest/services/myfolder/myservice/GPServer?&amp;lt;token&lt;/A&gt;&amp;nbsp;here&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4c4c4c; background-color: #ffffff;"&gt;Am I misunderstanding what tokens do?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Oct 2018 18:01:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/help-me-understand-tokens/m-p/293252#M11312</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2018-10-19T18:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Help me understand tokens</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/help-me-understand-tokens/m-p/293253#M11313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The first thing that comes to mind, (and only because you didn't explicitly mention it), is that you're not sending the same value of the referer header as the one you use to generate the token. They have to match exactly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Oct 2018 23:05:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/help-me-understand-tokens/m-p/293253#M11313</guid>
      <dc:creator>JonathanQuinn</dc:creator>
      <dc:date>2018-10-19T23:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help me understand tokens</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/help-me-understand-tokens/m-p/293254#M11314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So you're saying in the HTTP referrer field, I should be using &lt;A href="https://www.domain.com/serverName/"&gt;https://www.domain.com/serverName/&lt;/A&gt;&amp;nbsp; ? Or would it be &lt;A href="https://www.domain.com/serverName/myfolder/myservice/GPServer"&gt;https://www.domain.com/serverName/myfolder/myservice/GPServer&lt;/A&gt;&amp;nbsp;? The domain our web app sits on and the token URL are the same domain, if that matters.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 20 Oct 2018 12:15:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/help-me-understand-tokens/m-p/293254#M11314</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2018-10-20T12:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help me understand tokens</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/help-me-understand-tokens/m-p/293255#M11315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The final URL should look like this...what I was missing was defining the task after you define what type of server you're trying to access:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.domain.com/serverName/myfolder/myservice/GPServer/task?&amp;lt;token"&gt;https://www.domain.com/serverName/myfolder/myservice/typeOfServer/task?&amp;lt;token&lt;/A&gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/www.blahblahblah.org/natureServer/HabitatManagement/Habitatmanagement/GPServer/HabitatManagement?a89sd79faklj234fa087sljk34dadf878234klsd897234lksdoeroi" rel="nofollow" target="_blank"&gt;https://www.blahblahblah.org/natureServer/HabitatManagement/HabitatManagement/GPServer/HabitatManagement?a89sd79faklj234fa087sljk34dadf878234klsd897234lksdoeroi&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**Note that I am using the above URLs with a web adapter installed so I can access my services directly from my domain. If you're not using a web adapter then it'd be something more like this:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/serverName:6080/arcgis/HabitatManagement/HabitatManagement/GPServer/HabitatManagement" rel="nofollow" target="_blank"&gt;https://natureServer:6080/arcgis/HabitatManagement/HabitatManagement/GPServer/HabitatManagement&lt;/A&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;A _jive_internal="true" class="" href="https://community.esri.com/www.blahblahblah.org/natureServer/HabitatManagement/Habitatmanagement/GPServer/HabitatManagement?a89sd79faklj234fa087sljk34dadf878234klsd897234lksdoeroi" rel="nofollow" style="color: #2989c5; text-decoration: none; padding-right: calc(12px + 0.35ex);" target="_blank"&gt;a89sd79faklj234fa087sljk34dadf878234klsd897234lksdoeroi&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To illustrate this further, from your main rest services page, your folders:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="424992" alt="" class="image-4 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/424992_Capture.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I click on HabitatManagement, I get taken to my services:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="424978" alt="" class="image-2 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/424978_Capture.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I click on that service, I get taken to my tasks&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="424991" alt="" class="image-3 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/424991_Capture.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Those make up the three parts of your URL. After you append the token to end of that (don't forget the question mark!) then it should log you in automatically and give you access.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Oct 2018 15:11:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/help-me-understand-tokens/m-p/293255#M11315</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2018-10-22T15:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Help me understand tokens</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/help-me-understand-tokens/m-p/293256#M11316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm glad that it's working, but I'm surprised it was a problem with the URL and not with the referer. For example:&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; urllib&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; urllib2&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; json&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; traceback&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ssltoken
URL &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fsampleserver6.arcgisonline.com%2Farcgis%2Ftokens%2FgenerateToken" target="_blank"&gt;https://sampleserver6.arcgisonline.com/arcgis/tokens/generateToken&lt;/A&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;/SPAN&gt;
tokenParams &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; dict&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;username&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'user1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;password&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'user1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;client&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'referer'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;expiration&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'1440'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;referer&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fserver.domain.com" target="_blank"&gt;https://server.domain.com&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;f&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"json"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
tokenRequest &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; urllib&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;urlopen&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tokenURL&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;urllib&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;urlencode&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tokenParams&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
jsonResponse &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; json&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;loads&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tokenRequest&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;read&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
token &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; jsonResponse&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="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;I create a referer based token. If I make a request without providing any headers, I get invalid token:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;restParams &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; dict&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;f&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"json"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;token&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;token&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
restRequest &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; urllib&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;urlopen&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fsampleserver6.arcgisonline.com%2Farcgis%2Frest%2Fservices" target="_blank"&gt;https://sampleserver6.arcgisonline.com/arcgis/rest/services&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;urllib&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;urlencode&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;restParams&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;restRequest&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;read&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"error"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"code"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;498&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"message"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Invalid Token"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"details"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&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;If I use a different referer, I get the same response:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;request &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; urllib2&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Request&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fsampleserver6.arcgisonline.com%2Farcgis%2Frest%2Fservices" target="_blank"&gt;https://sampleserver6.arcgisonline.com/arcgis/rest/services&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
request&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;add_header&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'referer'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fserver" target="_blank"&gt;https://server&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
restRequest &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; urllib2&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;urlopen&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;request&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;urllib&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;urlencode&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;restParams&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;restRequest&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;read&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"error"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"code"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;498&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"message"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Invalid Token"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"details"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if I use the correct referer, then it works:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;request &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; urllib2&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Request&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fsampleserver6.arcgisonline.com%2Farcgis%2Frest%2Fservices" target="_blank"&gt;https://sampleserver6.arcgisonline.com/arcgis/rest/services&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
request&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;add_header&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'referer'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fserver.domain.com" target="_blank"&gt;https://server.domain.com&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
restRequest &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; urllib2&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;urlopen&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;request&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;urllib&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;urlencode&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;restParams&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;restRequest&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;read&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"currentVersion"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;10.6&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"folders"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"AGP"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Elevation"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Energy"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"LocalGovernment"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Locators"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"NetworkAnalysis"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Oblique"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"OsoLandslide"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"ScientificData"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"StoryMaps"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Sync"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Utilities"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"services"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"name"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"911CallsHotspot"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"type"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"GPServer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"name"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"911CallsHotspot"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"type"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MapServer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"name"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Census"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"type"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MapServer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"name"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CharlotteLAS"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"type"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"ImageServer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"name"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CommercialDamageAssessment"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the valid referer was sent along with the request to an invalid page, you shouldn't get an invalid token response.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:06:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/help-me-understand-tokens/m-p/293256#M11316</guid>
      <dc:creator>JonathanQuinn</dc:creator>
      <dc:date>2021-12-11T14:06:36Z</dc:date>
    </item>
  </channel>
</rss>

