<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Questions regarding apiKey usage on layers loaded from AGOL and requests to utility.arcgis.com in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/questions-regarding-apikey-usage-on-layers-loaded/m-p/1699793#M88402</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am having some trouble with the authentication of a layer loaded from a Portal item when using the ArcGIS Maps SDK for JavaScript. I was hoping you could clarify if I’m missing a configuration step or if I’ve encountered a known behaviour.&lt;/P&gt;&lt;P&gt;The Scenario: I am loading a specific layer from a Portal item and providing an apiKey directly in the portalItem configuration:&lt;/P&gt;&lt;PRE&gt;const layer = await Layer.fromPortalItem({&lt;BR /&gt;  portalItem: {&lt;BR /&gt;    id: "MY_LAYERS_PORTAL_ID",&lt;BR /&gt;    apiKey: "MY_SPECIFIC_API_KEY"&lt;BR /&gt;  }&lt;BR /&gt;});&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;In my application, I also use a global request interceptor that manages dynamic tokens for other general services by updating esriConfig.apiKey.&lt;/P&gt;&lt;PRE&gt;esriConfig.request.interceptors.unshift({&lt;BR /&gt;  async before() {&lt;BR /&gt;    esriConfig.apiKey = await getEsriToken();&lt;BR /&gt;  }&lt;BR /&gt;  urls: [&lt;BR /&gt;    'https://www.arcgis.com',&lt;BR /&gt;    'https://snla.maps.arcgis.com',&lt;BR /&gt;    'https://services-eu1.arcgis.com',&lt;BR /&gt;    'https://utility.arcgis.com',&lt;BR /&gt;    'https://services-eu1.arcgis.com',&lt;BR /&gt;    'https://elevation.arcgis.com',&lt;BR /&gt;    'https://route-api.arcgis.com',&lt;BR /&gt;    'https://geocode.arcgis.com'&lt;BR /&gt;  ]&lt;BR /&gt;});&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The Problem: I've noticed that while the initial portal metadata requests (sharing/rest) correctly use the provided apiKey, the subsequent request for the layer data (routed through the utility service proxy) behaves differently:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;URL: &lt;EM&gt;&lt;A href="https://utility.arcgis.com/usrsvcs/servers/PORTAL_ID/rest/services/SERVICE_NAME/FeatureServer/0" target="_blank"&gt;https://utility.arcgis.com/usrsvcs/servers/PORTAL_ID/rest/services/SERVICE_NAME/FeatureServer/0&lt;/A&gt;&lt;/EM&gt; &lt;STRONG&gt;Uses the key from esriConfig.apiKey&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Observation: If I remove the utility.arcgis.com domain from my global interceptor, this request triggers an ArcGIS login prompt, suggesting it isn't using the apiKey I provided to the layer.&lt;/LI&gt;&lt;LI&gt;Conflict: If my global interceptor is active, the request uses the global esriConfig.apiKey instead of the layer-specific one, which causes an authentication failure for this private layer.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;My Questions:&lt;/STRONG&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Should requests routed through utility.arcgis.com automatically inherit the apiKey provided to the PortalItem or Layer?&lt;/LI&gt;&lt;LI&gt;Am I doing something wrong in how I'm passing the key? I tried setting the apiKey on the resulting layer instance or the portal object as well, without success.&lt;/LI&gt;&lt;LI&gt;Is there a recommended pattern for maintaining a global API key while allowing certain layers to use their own specific keys for proxied services?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Emil Aura&lt;/P&gt;</description>
    <pubDate>Mon, 04 May 2026 10:49:54 GMT</pubDate>
    <dc:creator>EmilAura</dc:creator>
    <dc:date>2026-05-04T10:49:54Z</dc:date>
    <item>
      <title>Questions regarding apiKey usage on layers loaded from AGOL and requests to utility.arcgis.com</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/questions-regarding-apikey-usage-on-layers-loaded/m-p/1699793#M88402</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am having some trouble with the authentication of a layer loaded from a Portal item when using the ArcGIS Maps SDK for JavaScript. I was hoping you could clarify if I’m missing a configuration step or if I’ve encountered a known behaviour.&lt;/P&gt;&lt;P&gt;The Scenario: I am loading a specific layer from a Portal item and providing an apiKey directly in the portalItem configuration:&lt;/P&gt;&lt;PRE&gt;const layer = await Layer.fromPortalItem({&lt;BR /&gt;  portalItem: {&lt;BR /&gt;    id: "MY_LAYERS_PORTAL_ID",&lt;BR /&gt;    apiKey: "MY_SPECIFIC_API_KEY"&lt;BR /&gt;  }&lt;BR /&gt;});&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;In my application, I also use a global request interceptor that manages dynamic tokens for other general services by updating esriConfig.apiKey.&lt;/P&gt;&lt;PRE&gt;esriConfig.request.interceptors.unshift({&lt;BR /&gt;  async before() {&lt;BR /&gt;    esriConfig.apiKey = await getEsriToken();&lt;BR /&gt;  }&lt;BR /&gt;  urls: [&lt;BR /&gt;    'https://www.arcgis.com',&lt;BR /&gt;    'https://snla.maps.arcgis.com',&lt;BR /&gt;    'https://services-eu1.arcgis.com',&lt;BR /&gt;    'https://utility.arcgis.com',&lt;BR /&gt;    'https://services-eu1.arcgis.com',&lt;BR /&gt;    'https://elevation.arcgis.com',&lt;BR /&gt;    'https://route-api.arcgis.com',&lt;BR /&gt;    'https://geocode.arcgis.com'&lt;BR /&gt;  ]&lt;BR /&gt;});&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The Problem: I've noticed that while the initial portal metadata requests (sharing/rest) correctly use the provided apiKey, the subsequent request for the layer data (routed through the utility service proxy) behaves differently:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;URL: &lt;EM&gt;&lt;A href="https://utility.arcgis.com/usrsvcs/servers/PORTAL_ID/rest/services/SERVICE_NAME/FeatureServer/0" target="_blank"&gt;https://utility.arcgis.com/usrsvcs/servers/PORTAL_ID/rest/services/SERVICE_NAME/FeatureServer/0&lt;/A&gt;&lt;/EM&gt; &lt;STRONG&gt;Uses the key from esriConfig.apiKey&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Observation: If I remove the utility.arcgis.com domain from my global interceptor, this request triggers an ArcGIS login prompt, suggesting it isn't using the apiKey I provided to the layer.&lt;/LI&gt;&lt;LI&gt;Conflict: If my global interceptor is active, the request uses the global esriConfig.apiKey instead of the layer-specific one, which causes an authentication failure for this private layer.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;My Questions:&lt;/STRONG&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Should requests routed through utility.arcgis.com automatically inherit the apiKey provided to the PortalItem or Layer?&lt;/LI&gt;&lt;LI&gt;Am I doing something wrong in how I'm passing the key? I tried setting the apiKey on the resulting layer instance or the portal object as well, without success.&lt;/LI&gt;&lt;LI&gt;Is there a recommended pattern for maintaining a global API key while allowing certain layers to use their own specific keys for proxied services?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Emil Aura&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2026 10:49:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/questions-regarding-apikey-usage-on-layers-loaded/m-p/1699793#M88402</guid>
      <dc:creator>EmilAura</dc:creator>
      <dc:date>2026-05-04T10:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Questions regarding apiKey usage on layers loaded from AGOL and requests to utility.arcgis.com</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/questions-regarding-apikey-usage-on-layers-loaded/m-p/1701589#M88416</link>
      <description>&lt;P&gt;Hi EmilAura,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can offer a recommendation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Remove the URL&amp;nbsp;&lt;A href="https://utility.arcgis.com" target="_blank" rel="noopener"&gt;https://utility.arcgis.com &lt;/A&gt;from your global API key config. As you said, this will prompt a login since it no longer has an API key to grant access.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead, set apiKeys (not apiKey) property with the right scope and services for your ArcGIS Portal items, services and also URL&amp;nbsp;&lt;A href="https://utility.arcgis.com.," target="_blank" rel="noopener"&gt;https://utility.arcgis.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;apiKey is used for globally configure API key, whereas apiKeys is used as more fine grained API Keys for specific classes.&lt;/P&gt;&lt;P&gt;In addition to your global API key configuration, set a apiKeys configuration for your specific portal and service URLs. Here is an example snippet from official documentation: &lt;A href="https://developers.arcgis.com/javascript/latest/references/core/config/#Config-apiKeys" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/references/core/config/#Config-apiKeys&lt;/A&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;// Set an API key for multiple services.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;config&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;apiKeys&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;scopes&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; [&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;// The API key value. This is for your portal API key&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;token&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"API_KEY_FOR_SERVICE"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;// An array of URLs that the API key applies to.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;//my recommendation is adding your&amp;nbsp;"&lt;A href="https://utility.arcgis.com" target="_blank" rel="noopener"&gt;https://utility.arcgis.com&lt;/A&gt;" here instead as well as your portal URL&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;urls&lt;/SPAN&gt;&lt;SPAN&gt;: [&lt;/SPAN&gt;&lt;SPAN&gt;portalURL&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;serverURL&lt;/SPAN&gt;&lt;SPAN&gt;]&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;},&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;// More scopes can be added here...&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;];&lt;BR /&gt;&lt;BR /&gt;This will probably suffice for all services coming from your ArcGIS Portal, no longer needing to set apiKey property in the portalItem object.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;Hope this helps. Let me know if this works for you.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2026 17:48:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/questions-regarding-apikey-usage-on-layers-loaded/m-p/1701589#M88416</guid>
      <dc:creator>ShlokWagle7</dc:creator>
      <dc:date>2026-05-12T17:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: Questions regarding apiKey usage on layers loaded from AGOL and requests to utility.arcgis.com</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/questions-regarding-apikey-usage-on-layers-loaded/m-p/1703178#M88456</link>
      <description>&lt;P&gt;Do you need an API Key at all when having a portal?&lt;BR /&gt;Doesnt the portal provide everything one needs when only defining a "WebApp"-Object in the Portal?&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2026 17:06:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/questions-regarding-apikey-usage-on-layers-loaded/m-p/1703178#M88456</guid>
      <dc:creator>SebastianKrings</dc:creator>
      <dc:date>2026-05-20T17:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: Questions regarding apiKey usage on layers loaded from AGOL and requests to utility.arcgis.com</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/questions-regarding-apikey-usage-on-layers-loaded/m-p/1703276#M88461</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/83360"&gt;@SebastianKrings&lt;/a&gt;&amp;nbsp; Any &lt;STRONG&gt;secured&lt;/STRONG&gt; content (web map, services) hosted in ArcGIS Portal or ArcGIS Online requires one of the three forms of authentication -- API key, temporary ArcGIS Token, or your OAuth 2.0 credentials.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If there is no API key or ArcGIS token provided for a secured Web Map in ArcGIS portal, the web app will prompt a default username and password login. The app will try to access the item from &lt;A href="https://arcgis.com" target="_blank" rel="noopener"&gt;https://arcgis.com&lt;/A&gt;&amp;nbsp;ArcGIS Online by default instead of your specific ArcGIS Enterprise portal.&lt;/P&gt;&lt;P&gt;When consuming secured items from Enterprise portal, you should add the portal URL to your esriConfig.apiKeys.scopes (for scoped config) or esriConfig.portralUrl (for global config) which will open a new browser window directed to your portal's ArcGIS OAuth 2.0 login.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2026 20:55:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/questions-regarding-apikey-usage-on-layers-loaded/m-p/1703276#M88461</guid>
      <dc:creator>ShlokWagle7</dc:creator>
      <dc:date>2026-05-20T20:55:29Z</dc:date>
    </item>
  </channel>
</rss>

