An API key has been configured to access the web map with item-level access privileges in an ArcGIS Enterprise deployment secured with IWA. However, when I attempt to access the web map by passing the API key through the token parameter, a Windows Authentication login prompt still appears asking for credentials. I need to know how to suppress this IWA prompt so that the API key can be used directly to access the item. We are using the ArcGIS Maps SDK for JavaScript 4.33 and ArcGIS Enterprise 11.5.
My current code looks like this:
esriConfig.apiKeys.scopes = [
{
// The API key value
token: apiKey,
// An array of URLs that the API key applies to
urls: [portalUrl]
}
];
const webmap = new WebMap({
portalItem: {
id: "<itemid>",
portal: {
url: portalUrl
}
// apiKey: apiKey
},
});
await webmap.loadAll();
But this throws the error:
message: "Failed to load portal item"
name: "webmap:load-portal-item"
How are API keys expected to work with ArcGIS Enterprise secured using IWA?
Did you see this recent post?
https://community.esri.com/t5/developers-questions/api-key-issues/td-p/1627931
Looks like you already are doing like its solved there.
But may you find sth. helpful.
For login we
useIdentityManager.getCredential(tokenUrl);
IdentityManager.checkAppAccess(tokenUrl, this._clientId ?? 'UNKNOWN');
The WebMap we create this way:
const webMap = new WebMap({ portalItem: { id: webMapId } });
await webMap.load();