Detect or prevent the ArcGIS authentication dialog if sent to map

750
2
Jump to solution
04-15-2021 07:33 AM
GregoryBologna
Occasional Contributor II

I consume ImageServer tiles from a partner's ArcGIS. Sometimes their ArcGIS server goes down or the permissions change after they republish, and it may be an hour or so before they resolve this. The problem is that the public will see the ArcGIS authentication dialog anytime the map is accessed (see screenshot). 

 

Here I create the ImageryTileLayer tlay.

var layerUrl = someArcGISUrl + "/" + year + "/AERIAL_" + year + (year > 2002 ? "_RGB" : "_BW") + "/ImageServer";
var tlay = new ImageryTileLayer({
url: layerUrl,
title: year
});

I don't want the authentication dialog to display. I have not found a way to detect or prevent it. It would be great to have a property that disables showing such dialogs.

Here I check for any errors, but "layerview-create-error" will be hit after the authentication dialog is cancelled.

tlay.when("layerview-create-error", function(event) {
console.info(event);
});

 

promptprompt

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor

It's a pretty unique request, and we don't doc this, don't really support it, so it could change at any point in the future without notice. This will also break any other legitimate OAuth you might have in your app, when tokens expire or other similar issues. Pretty much voids your warranty. You didn't get this from me.

 

 

IdentityManager.on("dialog-create", () => {
  IdentityManager.dialog.open = false;
});

 

https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#eve...

https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#dia...

View solution in original post

2 Replies
ReneRubalcava
Frequent Contributor

It's a pretty unique request, and we don't doc this, don't really support it, so it could change at any point in the future without notice. This will also break any other legitimate OAuth you might have in your app, when tokens expire or other similar issues. Pretty much voids your warranty. You didn't get this from me.

 

 

IdentityManager.on("dialog-create", () => {
  IdentityManager.dialog.open = false;
});

 

https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#eve...

https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#dia...

NilsBabel1
Occasional Contributor

Hi, I actually have the exact same problem.  I'm not sure this solution is actually fixing the problem or just masking it.  I have a resource proxy that handles storing the username/password and getting tokens for several of our layers because they come from different sources.  My problem is I have a few layers that come from an ArcGIS Online subscription.  The author has been changing the name of the service a few times.  In our application the JavaScript API can't find it and apparently thinks the layer might be secured so it opens the password dialog.  The solution listed above only closes the dialog it doesn't actually cancel it.  So my layer and view is still waiting for input and the updating property never gets set to false.  I want to close the dialog through the cancel button so that the layer's create-layer-error event get's called and the user is notified there is a problem with the layer.  Is there a way to do this?

I'm not sure why something like this would be unsupported.  It seems like a reasonable choice for the developer to present the user with the dialog or not.  Thanks very much.

0 Kudos