<?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 ArcGIS Token not working properly when creating programmatically  in ArcGIS Web AppBuilder Questions</title>
    <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/arcgis-token-not-working-properly-when-creating/m-p/188659#M5174</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am able to create ArcGIS Token for Secured Map Services using below code:&lt;/P&gt;&lt;P&gt;///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;public string createToken()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;string username = "siteadmin";&lt;BR /&gt; string password = "password";&lt;BR /&gt;&lt;SPAN&gt; string httpreferer = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2FMachineName%2FTest.html" rel="nofollow" target="_blank"&gt;http://MachineName/Test.html&lt;/A&gt;&lt;SPAN&gt;";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; string generateTokenUrl = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2FMachineName%3A6443%2Farcgis%2Ftokens%2FgenerateToken" rel="nofollow" target="_blank"&gt;https://MachineName:6443/arcgis/tokens/generateToken&lt;/A&gt;&lt;SPAN&gt;";&lt;/SPAN&gt;&lt;BR /&gt;int exp = 60;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; if (!string.IsNullOrEmpty(username) &amp;amp;&amp;amp; !string.IsNullOrEmpty(password))&lt;BR /&gt; {&lt;BR /&gt; TokenModel tokenModel = new TokenModel(username, password, httpreferer, exp);&lt;/P&gt;&lt;P&gt;string post = tokenModel.GetQueryStringParameter();&lt;BR /&gt; WebClient clientToken = new WebClient();&lt;BR /&gt; clientToken.Headers.Add("Content-Type: application/x-www-form-urlencoded");&lt;BR /&gt; string tokenResult = clientToken.UploadString(generateTokenUrl, post);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return&amp;nbsp;&lt;SPAN&gt;tokenResult&amp;nbsp;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;public string GetQueryStringParameter()&lt;BR /&gt; {&lt;BR /&gt; return "f=" + this.f + "&amp;amp;username=" + this.username + "&amp;amp;password=" + this.password + "&amp;amp;referer=" + this.httpreferer + "&amp;amp;expiration=" + this.expiration;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;/P&gt;&lt;P&gt;The token generated from the above code is like this : &lt;STRONG&gt;jRI_CQUsuxytOHJaXAxqLyHL9N1hgBDbM8RtNiJLbLM.&amp;nbsp;&lt;/STRONG&gt;The above is token is not respecting the above&amp;nbsp;&lt;SPAN&gt;httpreferer&amp;nbsp;URL. If i am adding the above token to the same map service for different&amp;nbsp;site, its working. PFB Image for the same&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Correct Referer URL&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG __jive_id="392954" alt="Test.html" class="image-4 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/392954_test.html.png" style="width: 620px; height: 348px;" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Incorrect Referer URL&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG __jive_id="392955" alt="Token" class="image-5 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/392955_TokenHtmlPage.png" style="width: 620px; height: 348px;" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But when i manually created the token (from&amp;nbsp;&lt;A class="link-titled" href="https://infarszb11672.nmumarl.lntinfotech.com:6443/arcgis/tokens/generateToken" title="https://infarszb11672.nmumarl.lntinfotech.com:6443/arcgis/tokens/generateToken"&gt;https://MachineName:6443/arcgis/admin/generateToken&lt;/A&gt;&amp;nbsp; with the above referer (i.e.&amp;nbsp;&amp;nbsp;&lt;A href="http://MachineName/Test.html"&gt;http://MachineName/Test.html&lt;/A&gt;) , I am getting token like this:&amp;nbsp;&lt;STRONG&gt;WX8Fa7HdCJzgpJyTun8B5_lvoaJP2PzdkMxpAeW7phmGNd0aANCq5FSmetfI7n0tmy4CD7uo58ZA8gqRQouTYGLe5p4db0gs-Q_BNIjWT89ZjeUxxCj5e8dQpAd9xukX&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Which is quite big and working as expected (i.e. it is not allowing to access map service from any other http referer URL. One pop-up generated asking for user name &amp;amp; password.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I have change the "&lt;SPAN&gt;generateTokenUrl" parameter to&amp;nbsp;&lt;A href="https://infarszb11672.nmumarl.lntinfotech.com:6443/arcgis/tokens/generateToken" style="color: #2989c5; text-decoration: none;" title="https://infarszb11672.nmumarl.lntinfotech.com:6443/arcgis/tokens/generateToken"&gt;https://MachineName:6443/arcgis/admin/generateToken&lt;/A&gt;&amp;nbsp;and i got the token as expected (i.e. quite big as above). But it is not working for any application (i.e. neither for the&amp;nbsp;http referer URL nor any other application).A pop-up generated asking for user name &amp;amp; password. PFB Image&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG __jive_id="392953" alt="Test HTML" class="image-3 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/392953_TestError.png" style="width: 620px; height: 348px;" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to resolve this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Jan 2018 13:46:40 GMT</pubDate>
    <dc:creator>ShaikhRizuan</dc:creator>
    <dc:date>2018-01-16T13:46:40Z</dc:date>
    <item>
      <title>ArcGIS Token not working properly when creating programmatically</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/arcgis-token-not-working-properly-when-creating/m-p/188659#M5174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am able to create ArcGIS Token for Secured Map Services using below code:&lt;/P&gt;&lt;P&gt;///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;public string createToken()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;string username = "siteadmin";&lt;BR /&gt; string password = "password";&lt;BR /&gt;&lt;SPAN&gt; string httpreferer = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2FMachineName%2FTest.html" rel="nofollow" target="_blank"&gt;http://MachineName/Test.html&lt;/A&gt;&lt;SPAN&gt;";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; string generateTokenUrl = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2FMachineName%3A6443%2Farcgis%2Ftokens%2FgenerateToken" rel="nofollow" target="_blank"&gt;https://MachineName:6443/arcgis/tokens/generateToken&lt;/A&gt;&lt;SPAN&gt;";&lt;/SPAN&gt;&lt;BR /&gt;int exp = 60;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; if (!string.IsNullOrEmpty(username) &amp;amp;&amp;amp; !string.IsNullOrEmpty(password))&lt;BR /&gt; {&lt;BR /&gt; TokenModel tokenModel = new TokenModel(username, password, httpreferer, exp);&lt;/P&gt;&lt;P&gt;string post = tokenModel.GetQueryStringParameter();&lt;BR /&gt; WebClient clientToken = new WebClient();&lt;BR /&gt; clientToken.Headers.Add("Content-Type: application/x-www-form-urlencoded");&lt;BR /&gt; string tokenResult = clientToken.UploadString(generateTokenUrl, post);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return&amp;nbsp;&lt;SPAN&gt;tokenResult&amp;nbsp;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;public string GetQueryStringParameter()&lt;BR /&gt; {&lt;BR /&gt; return "f=" + this.f + "&amp;amp;username=" + this.username + "&amp;amp;password=" + this.password + "&amp;amp;referer=" + this.httpreferer + "&amp;amp;expiration=" + this.expiration;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;/P&gt;&lt;P&gt;The token generated from the above code is like this : &lt;STRONG&gt;jRI_CQUsuxytOHJaXAxqLyHL9N1hgBDbM8RtNiJLbLM.&amp;nbsp;&lt;/STRONG&gt;The above is token is not respecting the above&amp;nbsp;&lt;SPAN&gt;httpreferer&amp;nbsp;URL. If i am adding the above token to the same map service for different&amp;nbsp;site, its working. PFB Image for the same&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Correct Referer URL&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG __jive_id="392954" alt="Test.html" class="image-4 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/392954_test.html.png" style="width: 620px; height: 348px;" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Incorrect Referer URL&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG __jive_id="392955" alt="Token" class="image-5 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/392955_TokenHtmlPage.png" style="width: 620px; height: 348px;" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But when i manually created the token (from&amp;nbsp;&lt;A class="link-titled" href="https://infarszb11672.nmumarl.lntinfotech.com:6443/arcgis/tokens/generateToken" title="https://infarszb11672.nmumarl.lntinfotech.com:6443/arcgis/tokens/generateToken"&gt;https://MachineName:6443/arcgis/admin/generateToken&lt;/A&gt;&amp;nbsp; with the above referer (i.e.&amp;nbsp;&amp;nbsp;&lt;A href="http://MachineName/Test.html"&gt;http://MachineName/Test.html&lt;/A&gt;) , I am getting token like this:&amp;nbsp;&lt;STRONG&gt;WX8Fa7HdCJzgpJyTun8B5_lvoaJP2PzdkMxpAeW7phmGNd0aANCq5FSmetfI7n0tmy4CD7uo58ZA8gqRQouTYGLe5p4db0gs-Q_BNIjWT89ZjeUxxCj5e8dQpAd9xukX&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Which is quite big and working as expected (i.e. it is not allowing to access map service from any other http referer URL. One pop-up generated asking for user name &amp;amp; password.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I have change the "&lt;SPAN&gt;generateTokenUrl" parameter to&amp;nbsp;&lt;A href="https://infarszb11672.nmumarl.lntinfotech.com:6443/arcgis/tokens/generateToken" style="color: #2989c5; text-decoration: none;" title="https://infarszb11672.nmumarl.lntinfotech.com:6443/arcgis/tokens/generateToken"&gt;https://MachineName:6443/arcgis/admin/generateToken&lt;/A&gt;&amp;nbsp;and i got the token as expected (i.e. quite big as above). But it is not working for any application (i.e. neither for the&amp;nbsp;http referer URL nor any other application).A pop-up generated asking for user name &amp;amp; password. PFB Image&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG __jive_id="392953" alt="Test HTML" class="image-3 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/392953_TestError.png" style="width: 620px; height: 348px;" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to resolve this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 13:46:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/arcgis-token-not-working-properly-when-creating/m-p/188659#M5174</guid>
      <dc:creator>ShaikhRizuan</dc:creator>
      <dc:date>2018-01-16T13:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Token not working properly when creating programmatically</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/arcgis-token-not-working-properly-when-creating/m-p/188660#M5175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;U need to use the token per each layer u want to add in the map. If u dont do that, it will pop up the login window.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 14:17:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/arcgis-token-not-working-properly-when-creating/m-p/188660#M5175</guid>
      <dc:creator>EvelynHernandez</dc:creator>
      <dc:date>2018-01-16T14:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Token not working properly when creating programmatically</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/arcgis-token-not-working-properly-when-creating/m-p/188661#M5176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is only one layer in the map service.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 14:31:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/arcgis-token-not-working-properly-when-creating/m-p/188661#M5176</guid>
      <dc:creator>ShaikhRizuan</dc:creator>
      <dc:date>2018-01-16T14:31:20Z</dc:date>
    </item>
  </channel>
</rss>

