AnsweredAssumed Answered

JSAPI: generating a security token from on-premise token server in code

Question asked by vandervoort on Dec 26, 2014
Latest reply on Dec 29, 2014 by HHeijenga-esristaff

I'm struggling to generate a security token from my on-premise token server. The SDK's documentation is not obvious.


My code is:


        var si = new esri.ServerInfo();

        si.tokenServiceUrl = "";

        var imb = new esri.IdentityManagerBase();

        imb.on("credential-create", createdCredential);



          userInfo:{userName:"MyUserName", password:"MyPassword"}



I want to catch the token in the createdCredential method.


This code throws an error in the JSAPI API:

TypeError: r is undefined

Line 663


We do not want to use the out-of-the-box login that comes with esri.IdentityManager, instead we want to generate our own tokens and credentials. I can use query GET to get a token and I can use esri.request to get a token so long as I enable a proxy, but the code is a bit messy and defeats the purpose of the ArcGIS JSAPI.


TIA for any guidance you can offer.