I am building a web map application using the ArcGIS API for JavaScript. The application is using the GeoCoder widget from ESRI, but I need to link it to an outside, secured resource. I am able to use the outside server to create a token from my credentials, but I don't know how to append the token information to the GeoCoder widget.

I am looking for the correct way to add the token information into my geocoding requests. I have been scouring the forums here and on GeoNet, and the information I find points mostly to using either the IdentifyManager or using a proxy. The outside server lets me create a token that is valid for 1 year, so I would prefer to do that right now and set up the IdentifyManager or proxy later.

My site is HTML/JavaScript based on an IIS (6.1) server, and I was not planning on making it an ASP site.

I would prefer if I just take my credentials and create a token to quickly insert into my application rather than taking the time to set up the other methods.

Is there a way to take the web-generated token and pass it into the GeoCoder widget?

1 Answer 1


Ok.. After a morning of messing with this and trying to find a property to accomplish what I need, I was able to do this through the URL parameter of the geocoder.

When creating the array of geocoding services to add to the Geocoder widget, I needed to append that URL with the token information.

var myGeocoders = [{url: myURL/GeocodeServer/?token=MYTOKENINFO, name: "SingleField", placeholder: "Locate", outFields: "*", singleLineFieldName: "SingleLine"}];

When creating the token through the outside server's interface, I am able to restrict it to my web map's URL and can set the expiration date based on their settings.

So, with this current set up, I will need to edit my JS code to update the token (until I make it auto-generated) when it expires, but it allows me a shortcut into using secured geocoding services.

  • this is an unsafe option. you should be using a proxy to hide the token and credentials from end users of your application if you want to authenticate on their behalf. setting one up is more straightforward than you might imagine. github.com/esri/resource-proxy Dec 2, 2014 at 0:55
  • My end goal is to route through a proxy, but this is more of a 'it needs to work now' situation where I am not given the time to properly set it up currently. My credentials are not anywhere near the site (not even on my server), and the token is locked into the URL of my site so it can only be used from my site. For the time being, this set up will work, but I do plan on going the proxy route soon enough. Mostly so I don't have to regenerate the token when it expires.
    – Branco
    Dec 2, 2014 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.