AnsweredAssumed Answered

Token update using removeLayer, addLayer. Is there a better way?

Question asked by abjones on Feb 11, 2015
Latest reply on Feb 19, 2015 by abjones

I have reviewed many discussions on this forum where a desire is expressed to refresh access tokens using JavaScript. I have not found an elegant solution.


Is there a better way?  Just updating the .url property of a layer with a fresh token does not work.  A not very elegant way to change a token is to use method removeLayer followed by method addLayer with a url string that includes a fresh token ( many undesirable side effects ).


I want to manage access based on credentials entered on my login page.  On Windows platform running IIS, It is easy to get a fresh token string from a process running in the same IIS Session used by login page with all sensitive credentials safe as Session variables.  A fresh token string can easily be obtained by JavaScript in a subsequent map web page run in the same session with a new layer added using this token part of the url parameter.  What is surprisingly not easy is to update an existing map layer's access token.  I do not understand how to best do this using JavaScript API documentation.