<?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 How to get a token when CORS and HTTPS are in play? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-a-token-when-cors-and-https-are-in-play/m-p/185344#M17232</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm writing a mobile web application. The requirements are:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt; &lt;BR /&gt; &lt;LI&gt;A login screen (view) where username and password are entered. Therefore the IdentityManager singleton is not a valid option.&lt;/LI&gt; &lt;BR /&gt; &lt;LI&gt;Username and password are used to create a credential for *everything* in the application. Not just ArcGIS services, but also other services that use the same user store. These services use the token generated by the AGS token server.&lt;/LI&gt; &lt;BR /&gt; &lt;LI&gt;Dojo, jQuery and ArcGIS JavaScript API need to be hosted remotely. i.e., making use of content delivery network (CDN).&lt;/LI&gt; &lt;BR /&gt; &lt;LI&gt;The token server is, of course, secured: i.e., &lt;STRONG&gt;https&lt;/STRONG&gt;://www.MyServer.com/ArcGIS/tokens/&lt;/LI&gt; &lt;BR /&gt; &lt;LI&gt;The mobile application is not secured by SSL, i.e., &lt;A href="http://www.MyServer.com/MyApplication/login.html" rel="nofollow"&gt;http://www.MyServer.com/MyApplication/login.html&lt;/A&gt; and &lt;A href="http://www.MyServer.com/MyApplication/MapApp.html" rel="nofollow"&gt;http://www.MyServer.com/MyApplication/MapApp.html&lt;/A&gt; (no https).&lt;/LI&gt; &lt;BR /&gt; &lt;LI&gt;Exposing the token to the Internet is not an issue. In other words, &lt;A href="http://www.MyServer.com/MyApplication/MapApp.html?token=HugeBigHonkingLongTokenStringblahblahblah" rel="nofollow"&gt;http://www.MyServer.com/MyApplication/MapApp.html?token=HugeBigHonkingLongTokenStringblahblahblah&lt;/A&gt; is perfectly acceptable.&lt;/LI&gt; &lt;BR /&gt; &lt;LI&gt;The map application uses both local token-secured local GIS services and public Esri services. The SOM is on the same hardware as the web server (IIS). ArcGIS Server release is 10.0. No upgrade to 10.1 in the immediate future.&lt;/LI&gt; &lt;BR /&gt;&lt;/UL&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm really struggling with getting the token string. Under this scenarion, I'm using jQuery to get the token. I'm not familiar enough with Dojo to POST (yet).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; $.post(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; url, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; { request: request, clientid: clientid, expiration: expiration, username: userName, password : password }, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; function(data) { tokenSuccess(data);}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; );&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//(clientid is "requestip"_.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am having issues with CORS:&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;XMLHttpRequest cannot load &lt;/SPAN&gt;https://www.MyServer.com/ArcGIS/tokens/. Origin &lt;A href="http://www.MyServer.com" rel="nofollow"&gt;http://www.MyServer.com&lt;/A&gt; &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;is not allowed by Access-Control-Allow-Origin.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my web.config I have &lt;/SPAN&gt;&lt;STRONG&gt;Access-Control-Allow-Origin&lt;/STRONG&gt;&lt;SPAN&gt; wide open ("*") for now, I'll eventually ratchet it down to just the CDN providers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If there is an easier was to get the token string based on this scenario, I'm all ears. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Am I going to have to set up a proxy? Or can I just use CORS? Is IdentityManageBase an option?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TIA&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Nov 2012 16:32:58 GMT</pubDate>
    <dc:creator>DirkVandervoort</dc:creator>
    <dc:date>2012-11-06T16:32:58Z</dc:date>
    <item>
      <title>How to get a token when CORS and HTTPS are in play?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-a-token-when-cors-and-https-are-in-play/m-p/185344#M17232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm writing a mobile web application. The requirements are:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt; &lt;BR /&gt; &lt;LI&gt;A login screen (view) where username and password are entered. Therefore the IdentityManager singleton is not a valid option.&lt;/LI&gt; &lt;BR /&gt; &lt;LI&gt;Username and password are used to create a credential for *everything* in the application. Not just ArcGIS services, but also other services that use the same user store. These services use the token generated by the AGS token server.&lt;/LI&gt; &lt;BR /&gt; &lt;LI&gt;Dojo, jQuery and ArcGIS JavaScript API need to be hosted remotely. i.e., making use of content delivery network (CDN).&lt;/LI&gt; &lt;BR /&gt; &lt;LI&gt;The token server is, of course, secured: i.e., &lt;STRONG&gt;https&lt;/STRONG&gt;://www.MyServer.com/ArcGIS/tokens/&lt;/LI&gt; &lt;BR /&gt; &lt;LI&gt;The mobile application is not secured by SSL, i.e., &lt;A href="http://www.MyServer.com/MyApplication/login.html" rel="nofollow"&gt;http://www.MyServer.com/MyApplication/login.html&lt;/A&gt; and &lt;A href="http://www.MyServer.com/MyApplication/MapApp.html" rel="nofollow"&gt;http://www.MyServer.com/MyApplication/MapApp.html&lt;/A&gt; (no https).&lt;/LI&gt; &lt;BR /&gt; &lt;LI&gt;Exposing the token to the Internet is not an issue. In other words, &lt;A href="http://www.MyServer.com/MyApplication/MapApp.html?token=HugeBigHonkingLongTokenStringblahblahblah" rel="nofollow"&gt;http://www.MyServer.com/MyApplication/MapApp.html?token=HugeBigHonkingLongTokenStringblahblahblah&lt;/A&gt; is perfectly acceptable.&lt;/LI&gt; &lt;BR /&gt; &lt;LI&gt;The map application uses both local token-secured local GIS services and public Esri services. The SOM is on the same hardware as the web server (IIS). ArcGIS Server release is 10.0. No upgrade to 10.1 in the immediate future.&lt;/LI&gt; &lt;BR /&gt;&lt;/UL&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm really struggling with getting the token string. Under this scenarion, I'm using jQuery to get the token. I'm not familiar enough with Dojo to POST (yet).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; $.post(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; url, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; { request: request, clientid: clientid, expiration: expiration, username: userName, password : password }, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; function(data) { tokenSuccess(data);}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; );&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//(clientid is "requestip"_.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am having issues with CORS:&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;XMLHttpRequest cannot load &lt;/SPAN&gt;https://www.MyServer.com/ArcGIS/tokens/. Origin &lt;A href="http://www.MyServer.com" rel="nofollow"&gt;http://www.MyServer.com&lt;/A&gt; &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;is not allowed by Access-Control-Allow-Origin.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my web.config I have &lt;/SPAN&gt;&lt;STRONG&gt;Access-Control-Allow-Origin&lt;/STRONG&gt;&lt;SPAN&gt; wide open ("*") for now, I'll eventually ratchet it down to just the CDN providers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If there is an easier was to get the token string based on this scenario, I'm all ears. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Am I going to have to set up a proxy? Or can I just use CORS? Is IdentityManageBase an option?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TIA&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Nov 2012 16:32:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-a-token-when-cors-and-https-are-in-play/m-p/185344#M17232</guid>
      <dc:creator>DirkVandervoort</dc:creator>
      <dc:date>2012-11-06T16:32:58Z</dc:date>
    </item>
  </channel>
</rss>

