<?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 dynamic token generation in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205819#M19113</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using a token to access my arcgis secured services from JS APIs based application.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It works fine, but every time the token expires I need to generate a new one and substitute it directy in the js code. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I read that is possible to use a proxy page to send a request to the token service and generate the token dynamically by username and password (stored in the proxy page...). This would be ideal for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I found an example in aspx [1], but I need JSP and I don't understand how to adapt the default jsp proxy provided in the esri help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[1] &lt;/SPAN&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=158&amp;amp;f=2396&amp;amp;t=297001"&gt;http://forums.esri.com/Thread.asp?c=158&amp;amp;f=2396&amp;amp;t=297001&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Mar 2011 09:36:20 GMT</pubDate>
    <dc:creator>AlessioDi_Lorenzo1</dc:creator>
    <dc:date>2011-03-15T09:36:20Z</dc:date>
    <item>
      <title>dynamic token generation</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205819#M19113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using a token to access my arcgis secured services from JS APIs based application.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It works fine, but every time the token expires I need to generate a new one and substitute it directy in the js code. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I read that is possible to use a proxy page to send a request to the token service and generate the token dynamically by username and password (stored in the proxy page...). This would be ideal for me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I found an example in aspx [1], but I need JSP and I don't understand how to adapt the default jsp proxy provided in the esri help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[1] &lt;/SPAN&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=158&amp;amp;f=2396&amp;amp;t=297001"&gt;http://forums.esri.com/Thread.asp?c=158&amp;amp;f=2396&amp;amp;t=297001&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2011 09:36:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205819#M19113</guid>
      <dc:creator>AlessioDi_Lorenzo1</dc:creator>
      <dc:date>2011-03-15T09:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic token generation</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205820#M19114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, the same user here... &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry for the double registration, I forgot my username and the "magic question" answer to renew the password for this account, so I used "adilorenzo" to post and then I remembered how to login with my first account.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope someone can help me with the dynamic token...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2011 09:50:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205820#M19114</guid>
      <dc:creator>AlessioDi_Lorenzo</dc:creator>
      <dc:date>2011-03-15T09:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic token generation</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205821#M19115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Some additional information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Before facing the issue about dynamic token generation I tried the provided proxy.jsp as is just to see if it works. The comments in the proxy.jsp code says:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;String[] serverUrls = {
&amp;nbsp; //"&amp;lt;url&amp;gt;[,&amp;lt;token&amp;gt;]"
&amp;nbsp; //For ex. (secured server): "http://myserver.mycompany.com/arcgis/rest/services,ayn2C2iPvqjeqWoXwV6rjmr43kyo23mhIPnXz2CEiMA6rVu0xR0St8gKsd0olv8a"
&amp;nbsp; //For ex. (non-secured server): "http://sampleserver1.arcgisonline.com/arcgis/rest/services"
};&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;so I generated my Token in the token request page specificing, as usual: &lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;username/password &lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;IP address of the server sending the request to arcgis server (that is my local tomcat: 127.0.0.1:8080)&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;expiration time&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;BR /&gt;&lt;SPAN&gt;then I changed the JSP String[] serverUrls to this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
String[] serverUrls = {
"http://mydomain/arcgis/rest/services,my Token"
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I load the application page the secured layer request fails and firebug says:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{"error":{"code":498,"message":"Invalid token","details":[]}}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I'm doing wrong? Thanks...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In the Javascript part I wrote&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
esri.arcgis.gmaps.Config.alwaysUseProxy = true;
esri.arcgis.gmaps.Config.proxyUrl = "./proxy.jsp" 
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A note:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;when I use IP address to generate token, the authentication doen't work even if I pass the token directly in the javascript request. Otherwise it works when I use a token generated using the option Web Application URL or HTTP Referrer (but these token, as I read in the help, can't be used in the proxy page!)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:11:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205821#M19115</guid>
      <dc:creator>AlessioDi_Lorenzo</dc:creator>
      <dc:date>2021-12-11T10:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic token generation</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205822#M19116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;UP! News about proxy? Someone from esri staff...?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Mar 2011 06:56:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205822#M19116</guid>
      <dc:creator>AlessioDi_Lorenzo</dc:creator>
      <dc:date>2011-03-18T06:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic token generation</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205823#M19117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't know if posting to a thread that's over a year old will help, but I hate to start another one.&amp;nbsp; There are a ton of threads already on security, generating tokens and what you may or may not have to do to your proxy.config and proxy.ashx.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The first application I needed a proxy configuration for was because I was creating a buffer. I needed the request to be POST and so the examples from the Resource Center worked just fine once I added my server names to the proxy.config file.&amp;nbsp; I'm using the ASP.NET version.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I need to dynamically generate a token based on a user name/password.&amp;nbsp; I'm using a sample I found under Concepts.&amp;nbsp; ArcGIS Server Services &amp;gt; working with secure resources.&amp;nbsp; Under the section for working with tokens, there is a link to Security Sample.&amp;nbsp; Since the server I'm testing with is still at 9.3, it sounds like I need to be using esri.request.&amp;nbsp; (Apparently Identity Manager would help me, but that is only support at 10.0).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From the page I found this one, it's only viewable, I don't see how to download it.&amp;nbsp; It's not on the samples page and doesn't come up if you do a search on Security.&amp;nbsp; I was able to view the code through Firebug, but I'm lost on how the proxy is set up for it. I have tried both the original proxy.ashx file 'as-is' from the sample provided from "Using the proxy page" and a version that seems to be working for some that was posted on the forums under the thread "Token Security on an ArcGIS Server (Javascript)" as the file proxyDynamic.zip.&amp;nbsp; Neither are working for me.&amp;nbsp; I assume the solution to having your tokens truly dynamic lies in the ability to make a secure request back to your server hosting the services as opposed to trying to somehow store it in another external file, like web.config, that must be periodically edits with a new token.&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; I tried the original proxy.ashx and variation for dynamic tokens posted on the forums.&amp;nbsp; Both generate an error "malformed URI sequence".&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are over 1000 views on the main threads related to this, but very few answers.&amp;nbsp; Please, ESRI, review your pages on the configuration and use of secure services.&amp;nbsp; I can't be the only person who is getting lost on this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2012 16:23:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205823#M19117</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2012-11-02T16:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic token generation</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205824#M19118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Tracy, the simplest mode for check problems with proxy is: go in debug on ashx in Vs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However you can create your proxy. The esri only forwards request to a component server side with scope permission/filter. They are sample/helper but you should be set your logic security. I have seen sample without check for instance 'referrer'. It's true that you can bypass the REFERER security check...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2012 19:03:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205824#M19118</guid>
      <dc:creator>nicogis</dc:creator>
      <dc:date>2012-11-02T19:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic token generation</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205825#M19119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Unfortunately I do not have VS, I'm not likely to get a copy and I've never used it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe I don't need your modified ashx code.&amp;nbsp; In the file I see these lines:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;public string GetToken(string uri)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (ServerUrl su in serverUrls)
&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;&amp;nbsp; if (su.MatchAll &amp;amp;&amp;amp; uri.StartsWith(su.Url, StringComparison.InvariantCultureIgnoreCase) &amp;amp;&amp;amp; su.DynamicToken)
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Code to dynamically get the token
&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; string tokenService = string.Format("https://{0}/ArcGIS/tokens?request=getToken&amp;amp;username={1}&amp;amp;password={2}&amp;amp;expiration=30", su.Host, su.UserName, su.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; string token;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I interpret this to mean that 0, 1, 2 are parameters that are read from the proxy.config file.&amp;nbsp;&amp;nbsp; I want to be able to let the user enter their user name and password in a form, defining the variables dynamically, in this example usr and pwd.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;esri.request({
&amp;nbsp;&amp;nbsp;&amp;nbsp; url: "https://myserver.mo.gov/ArcGIS/tokens",
&amp;nbsp;&amp;nbsp;&amp;nbsp; content: {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; request: "getToken",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; username: usr,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; password: pwd
&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp; handleAs: "text",
&amp;nbsp;&amp;nbsp;&amp;nbsp; load: tokenObtained,
&amp;nbsp;&amp;nbsp;&amp;nbsp; error: tokenRequestFailed
&amp;nbsp; });&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do I not really need your modified proxy.ashx since that seems to be looking to proxy.config for these same parameters?&amp;nbsp; I didn't feel like the original proxy.ashx from the Resource Center was quite what I needed either.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:11:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamic-token-generation/m-p/205825#M19119</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2021-12-11T10:11:25Z</dc:date>
    </item>
  </channel>
</rss>

