How to avoid identity manager

4983
4
03-03-2015 08:32 PM
JianminYu
New Contributor

Hi, Currently I am building a customised login page for ArcGIS app using generateToken REST service.

This login can be done easily, and the response gives me correct token.

Now I need to access secure layers in my app, but I will encounter the Identity Manager popup for another login process.

Is there any method to avoid this popup ?

Can I manually to trigger the IdentityManager for authentication ?

Tags (1)
0 Kudos
4 Replies
JoelBennett
MVP Regular Contributor

You can probably get around this by appending the token to the query string of your layer's URL.  For example, you may have something like:

var url = "https://my-server.com/arcgis/rest/services/my-service/MapServer";
var layer = new ArcGISDynamicMapServiceLayer(url);

Instead, append the token like so:

var url = "https://my-server.com/arcgis/rest/services/my-service/MapServer?token=" + token;

This if course assumes your token is stored in a variable called "token".  Tokens expire too, so once it does, you'll probably see the identity popup again, unless you write code to manually acquire a new token.

JianminYu
New Contributor

Hi Joel,

Thanks.

This method works for displaying layers, but will encounter errors for getting legend information because of the duplicate ?token=....?token=.... using the legend widget.

After two days of trials, I have solved this problem.

Please see at Bypass IdentityManager Popup in ESRI ArcGIS JavaScript API | River on Bridge...

0 Kudos
JoelBennett
MVP Regular Contributor

Very good...it's always good to see somebody devising their own solutions.

Regarding the Legend dijit, this is a bug in ESRI's code that I've encountered and fixed on my locally hosted copy of the API (currently v3.12).  For what it's worth, in case it helps anybody else, here are my records of what I did:

esri\dijit\Legend.js - updated so token doesn't occur twice in query string


-updated second line of the _legendRequestServer function to:
  (c=a._getToken())&&(b+=((b.indexOf("?")==-1)?"?token\x3d"+c:((b.indexOf("token=")==-1)?"&token\x3d"+c:"")));

-original code was
(c=a._getToken())&&(b+="?token\x3d"+c);

-also updated similar line in _buildRow_Tools function:
(d=c._getToken())&&(g+=((g.indexOf("?")==-1)?"?token\x3d"+d:((g.indexOf("token=")==-1)?"&token\x3d"+d:"")))

-original code was (d=c._getToken())&&(g+="?token\x3d"+d)

  -Note - beware not to delete/overwrite the extra right parenthesis at the end of this line

0 Kudos
MayurPatel
New Contributor II

I also want to byPass Identity Manager PopUp. I implemented your code but still popup comes.
Have you written getCookieName('xyz') function to get UserID and token?

0 Kudos