AnsweredAssumed Answered

JavaScript Refresh credential and prevent Identity Manager pop-up

Question asked by abjones on Sep 9, 2014
Latest reply on Sep 11, 2014 by abjones

I want to use tokens with a short expire time,  generate a new token before expire, and then replace credentials for layers in a map.

My problem is how to prevent ArcGIS Identity Manager from continuing to create a pop-up requesting credentials.


I start with dom.byId('tokenText').value as a token having a short expire time.  I start a JavaScript timer giving 30 seconds to create a new token.

I try to update credentials; I'm not sure I know what I'm doing...  Pop-ups from Identity Manager occurs anyway.

Here is the "guts" of my work;  any suggestions will be cheerfully accepted!


var tokenText,layerSource;



ready(function() {


function renewToken(urlOfMapService){


// The URL of the request

        url: "refreshToken.aspx",

// Allow 10 seconds to get new token

        timeout: 10000,

// Send the existing token

        content: {

            token: tokenText


// The success callback with result from server

        load: function(result) {

//--- result is a Comma Separated Value string of creatTime, expireTime, tokenText

            var dataArray = result.split(',');




            initializeCredentials( dataArray );

  "Warblers").credential = credential;



// The error handler  

        error: function(message) {





function initializeCredentials(a) {

//--- a is Array  of creatTime, expireTime, tokenText, resourceURL

//--- call renewToken before expire

    waitTime = parseInt(a[1],10)

        - parseInt(a[0],10)

        - 30000;

    credentialsTimer = setTimeout(function(){renewToken(DGIFData)}, waitTime );


//--- fwisCredentials is a global Object variable assigned using JSON in a loaded script

    tokenText = a[2];

    credential = fwisCredentials.credentials[0];

    credential.creationTime = a[0];

    credential.expires = a[1];

    credential.token = tokenText;


    fwisCredentials.credentials = [credential];;

} = "";


    layerSource = "";


//--- initial token  and times are available at ready event

    tokenText = dom.byId('tokenText').value;


    initializeCredentials( [





    ]); = new esri.Map("map", {

        center: [-78.839150, 38.061840],

        zoom: 7,

        basemap: "topo",

        slider: true,


        logo: false,

        autoResize: true



//===LAYER LIST AND MAP SERVICES=======================================================================================


    var layerObject = new ArcGISDynamicMapServiceLayer(layerSource,

       { id: "Warblers", opacity: .8 });


    var flRegions = new FeatureLayer("", {

        mode: FeatureLayer.MODE_ONDEMAND

    });[flRegions, layerObject]);


  });  // ready function end