Select to view content in your preferred language

Is it possible to use a token in the Directions widget?

2652
3
09-11-2014 09:56 AM
KennethLyons
Emerging Contributor

I would like to start using the Directions Widget in my viewer again.  At this time I can select a start and end point, but then I'm prompted for a username/password.  That's not a problem for me, as I have an account, but the Viewer I have developed is used primarily for emergency response, so not all users will have a username/password nor will they really have time to create one on the fly when directions would be needed.  My questions is, is there anyway to add something akin to a token to whatever the default service is that used to generate the directions?

Thank you

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Ken,

  sure you can use a proxy for this. The proxy at Esri/resource-proxy · GitHub allows for you to setup the user name and password that will be used and even setting a limit so that you do not go over your credit quota

Robert

0 Kudos
JasonZou
Frequent Contributor

We have experienced the same issue for one of our apps. Here is what we did to resolve the issue.

  • Register the app with ArcGIS Online.
  • Once registered, click on the app link to go to the app info page.
  • Under App Registration, you will see the App ID and App Secret.
  • Download the ESRI proxy page via Releases · Esri/resource-proxy · GitHub. If you are using .NET, that will work. The java version has a bug. Let me know if you happen using Java version.
  • Add two serverUrl entries in proxy.config as below:

         <serverUrl url="http://route.arcgis.com"

                 clientId="the_app_id"

                 clientSecret="the_app_secret"

                 matchAll="true"/>

         <serverUrl url="http://traffic.arcgis.com"

                 clientId="the_app_id"

                 clientSecret="the_app_secret"

                 matchAll="true"/>

  • Whenever the app hits route.arcgis.com or traffic.arcgis.com which the Directions dijit does, the app will use the proxy page with the client id and secret to request for the token. Once the token is expired after maybe 2 hours, the proxy page will request for a refresh token. But all these happens behind the scene. The app id will be charged for any credits for using the routing service.

Hope it helps. Good luck.

Jason Zou

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jason,

  I think you may want to delete your post as you are providing code for the JavaScript API and the OP was asking about ArcGIS Viewer for Flex (based on the space this question is in).

0 Kudos