Hi,
I am trying to access the route service ,but while doing so I get the following error.
code":499,"message":"Token Required" The localhost is being generated from Visual studio once I configured the Javascript SDK frok ESRI. At the same time I just downloaded the routing example and with Dotnet proxy file I have hosted through IIS. The routing is working for me. Any possible reason why its behaving like this? Below is the proxy used in IIS <?xml version="1.0" encoding="utf-8" ?> <ProxyConfig allowedReferers="*" mustMatch="true"> <serverUrls> <serverUrl url="http://services.arcgisonline.com" matchAll="true"/> <serverUrl url="https://route.arcgis.com" username="xxxxx" password="xxxxx" matchAll="true"/> </serverUrls> </ProxyConfig> and the proxy used in Visual studio. <?xml version="1.0" encoding="utf-8" ?> <!-- Proxy config is used to set the ArcGIS Server services that the proxy will forward to. mustMatch: true to only proxy to sites listed, false to proxy to any site --> <ProxyConfig mustMatch="false"> <serverItems> <!-- serverUrl options: url = location of the ArcGIS Server, either specific URL or stem matchAll = true to forward any request beginning with the url token = (optional) token to include for token secured services, usually a long-term token tokenUrl = (optional) token service for a Web site (url) timeout = (optional) short-term timeout for a token in minutes username = (optional) username for a token or http secured site password = (optional) password for a token or http secured site domain = (optional) domain for an http secured site --> <serverItem url="http://sampleserver1.arcgisonline.com/arcgis/rest/services" matchAll="true" /> <serverItem url="http://sampleserver2.esri.com/arcgis/rest/services/" matchAll="true" /> <serverItem url="http://server.arcgisonline.com/arcgis/rest/services" matchAll="true" /> <serverItem url="http://xxxxx/xxxxx/rest/services" matchAll="true" tokenUrl="http://xxxxx/axxxxxx/tokens" username="xxxxxx" password="xxxxx" timeout="5" /> <serverItem url="http://xxxxx/ArcGIS/rest/services" matchAll="true" domain="xxxxx" username="xxxx" password="xxxx" /> <serverItem url="http://geocode.arcgis.com" username="xxxx" password="xxxxx" matchAll ="true"/> <serverItem url="https://route.arcgis.com" username="xxxxxx" password="xxxxxx" matchAll="true"/> </serverItems> </ProxyConfig>
Thanks
Kumar
Edit: The first example in the browser probably should have actually worked if the proxy was working correctly, because if I sign-in, I can see the service with the f=json
Original Post:
I'm not 100% sure what your question is. In the first example, it looks like you are trying to access the service REST endpoint directly in the browser, which should not work as I believe the services directory is locked down for security reasons. In the second example, you are looking at the results of the routing service request, which should work fine (and does).
Hi Noah,
My concern is the nature of proxy/route services. At some point it works fine while when I go in other environment the same throws token error.
So the service works correctly through the Esri Resource Proxy? But what proxy is being used in the first example that does not work?
Another option would be to use the ArcGIS Online hosted proxy for tasks like routing:
We use this now with the RouteTask sample:
https://developers.arcgis.com/javascript/latest/sample-code/tasks-route/index.html