Public web application using secured hosted services where log in is not required.

806
5
Jump to solution
05-13-2013 08:05 AM
SölviBergsveinsson
Esri Contributor
What is the best approach to make JavaScript web application where no log in is required that uses either ArcGIS Online secured hosted services or web map that is not shared?
In other words we want the JavaScript web application to be public but not the web map that is used in the application.

Any suggestions?

Thanks,
Solvi Thor
0 Kudos
1 Solution

Accepted Solutions
MikeTschudi
Occasional Contributor
Hi Solvi,

You might use proxy.ashx & proxy.config from Esri's map-and-app-gallery app on GitHub to automatically generate the token that Jian refers to. The map-and-app-gallery app presents a gallery of maps and apps that are shared with an ArcGIS.com group, and that group and the items can be private, so the proxy provides the authentication that the app needs without exposing the username and password to the browser. The proxy program works with a personal or organizational ArcGIS.com account.

Drop the two files into your site, make the site an IIS .Net version 4 application, and change the applicationURL, username, and password items in proxy.config. Send your URLs to the proxy.ashx and the authentication will be handled for you.

Regards,
Mike

View solution in original post

0 Kudos
5 Replies
JianHuang
Occasional Contributor III
You can simply add token at the end of the url when creating the layer.
For example:

var layer = new esri.layers.ArcGISTiledMapServiceLayer("serviceUrl/token=your_token");
map.addLayer(layer);
0 Kudos
MikeTschudi
Occasional Contributor
Hi Solvi,

You might use proxy.ashx & proxy.config from Esri's map-and-app-gallery app on GitHub to automatically generate the token that Jian refers to. The map-and-app-gallery app presents a gallery of maps and apps that are shared with an ArcGIS.com group, and that group and the items can be private, so the proxy provides the authentication that the app needs without exposing the username and password to the browser. The proxy program works with a personal or organizational ArcGIS.com account.

Drop the two files into your site, make the site an IIS .Net version 4 application, and change the applicationURL, username, and password items in proxy.config. Send your URLs to the proxy.ashx and the authentication will be handled for you.

Regards,
Mike
0 Kudos
SölviBergsveinsson
Esri Contributor
Thanks
I will try this solution.
0 Kudos
JeffHaney
New Contributor II
Mike,


Send your URLs to the proxy.ashx and the authentication will be handled for you.


Do you have an example of routing URLs to the proxy page?

Thanks,
Jeff
0 Kudos
AndyBurns
Occasional Contributor
Something like this should work....

    <serverUrl url="http://sampleserver2.arcgisonline.com/arcgis/rest/services/" 
               matchAll="true" 
               token="jijdfihjd023r33yr837r37"></serverUrl>


Ensure you have set up your proxy page correctly and use the following in your application/code:

   esri.config.defaults.io.proxyUrl = "your_location_to_proxy_page/proxy.ashx";
           esri.config.defaults.io.alwaysUseProxy = "true";

0 Kudos