Directions Widget Configure Proxy we have subscription

2999
9
04-08-2013 09:37 AM
LuciHawkins
Occasional Contributor III
We are trying to add the directions widget to our javascript website.  I am using the new 3.4 api.  I have the directions widget showing up in a content pane.  I can enter addresses in the widget.   I know it is a "paid" subscription service.  We have paid for the service.  Everything keeps pointing me to a proxy page.  I have downloaded the appropriate proxy for .net, I have added the proxy app to my IIS.  I think I have configured the proxy.config file with the correct information for obtaining the token, but I am not really sure.  Here is where I am getting lost.  Anyone familiar with setting this up? 

Thanks in advance!

Luci
0 Kudos
9 Replies
HaroldBostic
Occasional Contributor II
What have you done in your proxy config to create the token?
0 Kudos
JohnGravois
Frequent Contributor
i just tried standing up our published sample on my own machine, and made sure to reference my own proxy (without bothering to embed a token or credentials in the proxy.config).  this caused a security prompt to display in the application when I attempted to calculate a route, which gave me the opportunity to supply my ArcGIS for Organization credentials and get a successful result.

[ATTACH=CONFIG]23350[/ATTACH]

what happens on your side?
can you take a look at the network traffic and check for 404,403 errors etc.?
0 Kudos
HaroldBostic
Occasional Contributor II
I used a proxy on my remote server and get an internal error that I have not looked into yet.  I'll use a local proxy and see if I have better success
0 Kudos
LuciHawkins
Occasional Contributor III
Well, that is what I am not sure of, correctly setting up the proxy.  Here is what I have in the proxy.config file:

<?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="true">
  <serverUrls>
    <!-- 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 secured service
            dynamicToken = if true, gets token dynamically with username and
              password stored in web.config file's appSettings section.
    -->
<serverUrl url="https://www.arcgis.com/sharing/generateToken?parameters"
matchAll="true"
userName="our city username is entered here"
password="our city password is entered here"
referer="http://localhost/fwbjava/default.html"></serverUrl>
expiration="1440"
f="json"
  </serverUrls>
 
</ProxyConfig>


Anyone that uses our application will be on our network (either directly or via vpn) - it is not open to public - I do NOT want them to have to enter a username and password, especially those that are travelling in the fire engine responding to a call 🙂

Thanks,

Luci
0 Kudos
LuciHawkins
Occasional Contributor III
Ok, I changed these items:

Proxy config file:

<?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="true">
  <serverUrls>
    <!-- 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 secured service
            dynamicToken = if true, gets token dynamically with username and
              password stored in web.config file's appSettings section.
    -->
<serverUrl url="https://www.arcgis.com/sharing/generateToken?parameters"
matchAll="true"
dynamicToken = "true"
referer="http://localhost/fwbjava/default.html"></serverUrl>
expiration="1440"
f="json"
  </serverUrls>
 
</ProxyConfig>


web.config file in same proxy folder:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
userName="city username"
password="city password"
</configuration>


In Firebug I can see the 404 Not Found error for this URL:

callback=dojo.io.script.jsonp_dojoIoScript107._jsonpCallback
directionsLanguage=en
directionsLengthUnits=esriNAUMiles
directionsOutputType=esriDOTComplete
findBestSequence=false
http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve?f=json
outSR=102100
returnBarriers=false
returnDirections=true
returnPolygonBarriers=false
returnPolylineBarriers=false
returnRoutes=false
returnStops=false
stops={"type":"features","features":[{"geometry":{"x":-9642517.808238365,"y":3557110.1926639024,"spatialReference":{"wkid":102100}},"attributes":{"address":"51 Silva Dr NW, Fort Walton Beach, FL, 32548"}},{"geometry":{"x":-9642459.852759078,"y":3555678.421692784,"spatialReference":{"wkid":102100}},"attributes":{"address":"105 Miracle Strip Pky Sw, Fort Walton Beach, FL, 32548"}}],"doNotLocateOnRestrictedElements":true}


This is in my js app:

esri.addProxyRule({
  urlPrefix : "route.arcgis.com",
  proxyUrl : "/proxy"
});


I know I have something configured wrong in the Proxy, just wish I could find a book for dummies on how to set it up 🙂

Thank you!

Luci
0 Kudos
JohnGravois
Frequent Contributor
i still haven't figured out how to get my proxy to generate a token dynamically, but i was able to hard-code a long term token generated using a referrer and confirm that it allowed me to route without authenticating in my app.

these are the steps i used.
1.  ensured that the following two urls are listed as acceptable in my proxy.config
<serverUrl url="http://route.arcgis.com/arcgis/rest/services/"
               matchAll="true">
    </serverUrl>
<serverUrl url="http://www.arcgis.com/sharing/"
               matchAll="true">    
    </serverUrl>

2.  run the app and allow the identity manager to challenge and force a request to generate a token
3.  intercept the request in fiddler, right click, select "replay" and then "reissue and edit"
*this gives you a chance to specify a longer timeout and alter the referrer if desired
4.  place this new token in the proxy.config
<serverUrl url="http://route.arcgis.com/arcgis/rest/services/"
               matchAll="true"
               token="myreallylongtoken">
</serverUrl>

5.  afterward my app routed without a challenge

this process would be quite a bit more straightforward if there were a webpage where you could go to POST a request for a long-term token, but im guessing they disabled this option to minimize the proliferation of tokens (since this could deplete service credits)
0 Kudos
saraemani
New Contributor II
I was working on the proxy page error for past few days. tried to reconfigure .net on IIS. No luck. Were you able to solve the 404 error. Thanks
0 Kudos
MattLane
Occasional Contributor II
i still haven't figured out how to get my proxy to generate a token dynamically, but i was able to hard-code a long term token generated using a referrer and confirm that it allowed me to route without authenticating in my app.


Hey John, I also was trying to use the dynamicToken option in the proxy config, but looking at the aspx there is no code in there to use that. It would be nice if the proxy created a short lived token using the web.config appSettings (like the config directions say). I'd rather not have to create long-lived tokens.
0 Kudos
Noah-Sager
Esri Regular Contributor
I've had some success using a dynamic token in my proxy following this older forum post:

http://forums.esri.com/Thread.asp?c=158&f=2396&t=297001

Here's the relevant code snippet, see if this helps.

<!-- 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 secured service
            dynamicToken = if true, gets token dynamically with username and
            password stored in this file.
            userName = the secured user's username
            password = the password for the username
            host = the machine name that is hosting the map service
 -->


<serverUrl url="http://route.arcgis.com/arcgis/rest/services"
           matchAll="true"
           dynamicToken="true"
           host="host_name"
           userName="userName"
           password="password">
</serverUrl>
0 Kudos