webmap from json with token

1112
1
03-02-2014 12:51 PM
GregKnight
Occasional Contributor
Hi,

I am trying to embed a webmap with a demographics layer in an application. 

Ive followed much of the advice provided in this thread here:

http://forums.arcgis.com/threads/100095-Programmatically-Log-In-to-ArcGIS-Online-via-Javascript-Appl...

I am able to render the map/layer without a login, but I am getting some httpCode '498' | 'Invalid Token' | 'Unable to draw graphic (geometry: null, symbol: null) : Invalid Token' errors. There 6 of these for my webmap which includes 2 basemap layers and 1 operational (household income) operational layer. Also the popups for the demographics layer do not work.

Here's what I'm doing:

1.  Call a server-side class to get a token.

2.  Set esri.id = null to suppress the login. (this works)

3.  Create the webmap from json.  I am including the token in the layer object for my operational layer.

 webmap.itemData = {
    "operationalLayers": [{
      "url": "http://demographics1.arcgis.com/arcgis/rest/services/USA_Demographics_and_Boundaries/MapServer" + '?token=' + this.accessToken,
      "visibility": true,
      "opacity": 0.75,
      "title": "USA Average Household Income",
      "itemId": "3812e0b5526d4f8798840c86f9fd9ce7"
    }]


I have also tried iterating over the response to set the layerObject._url.query.token (per the above thread).  This isnt effective and seems unnecessary since my token value is is already sitting in that object key.

What am I missing here?

Thank you,
Greg
0 Kudos
1 Reply
GregKnight
Occasional Contributor
Well it seems that one can avoid all this mess with a properly configured proxy.

Livin' and Learnin'

Greg
0 Kudos