<?xml version="1.0" encoding="utf-8" ?> <ProxyConfig allowedReferers="*" mustMatch="false"> <serverUrls> <serverUrl url="http://services.arcgisonline.com" matchAll="true"/> <serverUrl url="http://arcgis.com" clientId="MYAPPID" clientSecret="MYSECRET" rateLimit="600" rateLimitPeriod="60" matchAll="true"> </serverUrl> </serverUrls> </ProxyConfig>
esriConfig.defaults.io.proxyUrl = "http://localhost:54254/proxy/proxy.ashx"; esriConfig.defaults.io.alwaysUseProxy = true;
Hi John
I have had a look at the proxy solution and I can't say I am a fan of the extra config doing it this way.
I have tried doing it this way.
http://forums.arcgis.com/threads/90031-Bypass-Identity-Manager-with-ArcGIS.com-OAuth-token-object?hi...
this for me is a much cleaner way of doing it but this does not work for me either. The code in the link still receives the challenge with a message saying I do not have access to the resource and if I use the 3.9 library there is no challenge and the map does not get drawn. I am running from localhost. The app set seems ok as I can get the token manually.
Do you know if the above method works with 3.9?
Ta,
D
<serverUrl url="http://www.arcgis.com"
username="john"
password="doe"
matchAll="true">
</serverUrl>
<!DOCTYPE html> <html> <head> <title>Create a Web Map</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <link rel="stylesheet" type="text/css" href="http://js.arcgis.com/3.8/js/esri/css/esri.css"> <style> html,body,#mapDiv,.map.container{ padding:0; margin:0; height:100%; } </style> <script>var dojoConfig = { parseOnLoad:true };</script> <script src="http://js.arcgis.com/3.9compact/"></script> <script> require([ "esri/map", "esri/arcgis/utils", "esri/urlUtils", "esri/config", "dojo/domReady!" ], function (Map, arcgisUtils, urlUtils, esriConfig) { //define proxy rule urlUtils.addProxyRule({ proxyUrl: "/sproxy/proxy.ashx", urlPrefix: "www.arcgis.com/sharing/rest" }); //swap for your own private webmap arcgisUtils.createMap("cd23069c1aeb44f79e072932d30bccac", "mapDiv"); }); </script> </head> <body> <div id="mapDiv"></div> </body> </html>
if (mustMatch) throw new ArgumentException("Proxy is being used for an unsupported service:");
Daniel,
if you snoop the web traffic when you launch your application you should see that a request to retreive the private webmap json is specifically whats failing.
http://www.arcgis.com/sharing/rest/content/items/cd23069c1aeb44f79e072932d30bccac/data?f=json
this can be resolved by adding the following serverUrl tag to your proxy.config.
<serverUrl url="http://www.arcgis.com" username="john" password="doe" matchAll="true"> </serverUrl>
after updating your proxy.config, try adapting this sample (i just confirmed it works fine)
<!DOCTYPE html> <html> <head> <title>Create a Web Map</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <link rel="stylesheet" type="text/css" href="http://js.arcgis.com/3.8/js/esri/css/esri.css"> <style> html,body,#mapDiv,.map.container{ padding:0; margin:0; height:100%; } </style> <script>var dojoConfig = { parseOnLoad:true };</script> <script src="http://js.arcgis.com/3.9compact/"></script> <script> require([ "esri/map", "esri/arcgis/utils", "esri/urlUtils", "esri/config", "dojo/domReady!" ], function (Map, arcgisUtils, urlUtils, esriConfig) { //define proxy rule urlUtils.addProxyRule({ proxyUrl: "/sproxy/proxy.ashx", urlPrefix: "www.arcgis.com/sharing/rest" }); //swap for your own private webmap arcgisUtils.createMap("cd23069c1aeb44f79e072932d30bccac", "mapDiv"); }); </script> </head> <body> <div id="mapDiv"></div> </body> </html>
yup. mustMatch="true" causes the proxy to compare the request to the whitelist in the proxy.config. if the url stub is not an exact match, it will throw an error rather than fetch the page and hand it back to you.
from what i saw before, you had 'arcgis.com' but not 'www.arcgis.com'.
Hi John
Indeed the issue was www however I am still having further trouble.
It still challenges and debugging the proxy I see that the following json is returned when it tries to get the actual map.
{"error":{"code":403,"messageCode":"GWM_0003","message":"You do not have permissions to access this resource or perform this operation.","details":[]}}
I have admin rights on the system and am using my credentials. I have checked the map is shared etc but do not seem to be able to locate any other settings that might affect this. Any ideas?
Thanks again for the taking the time to assist,
D
I have just manually generated the token and manually constructed map call and I get the same error so I am it does not look like the proxy is causing the problem. Could it be layers on the map?
glad to hear i was able to help sort you out.
you'll want to use either http or https across the board for resources and your actual application to avoid mixed protocol errors thrown by the browser.
http://yourmachine/folder/proxy.ashx?http://services2.arcgis.com/arcgis/blah....