<?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 Using API Key causes all public layers to be inaccessible in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-api-key-causes-all-public-layers-to-be/m-p/1685264#M88149</link>
    <description>&lt;P&gt;I hope everyone out there is having a good week.&lt;/P&gt;&lt;P&gt;I'm developing a custom web app using the JS Maps SDK and am accessing a lot of publicly available layers throughout the app.&amp;nbsp; I want to query a rainfall database and update a rainfall layer overnight so I added an API key to allow the app to edit my publicly available rainfall layer that is stored on our AGOL.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Adding the API key to the app causes all layers to return "invalid API key".&amp;nbsp; I can't specifically provide access for the API Key to layers I don't own, like state boundaries, etc.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;&lt;SPAN class=""&gt;[esri.layers.FeatureLayer] Failed to load layer (, 19c76fabfc4-layer-24) portal item (44801dcc31aa4085b38f540ac9947f62) [request:server]: Invalid token.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if I'm implementing it correctly because all of tutorial links in the documentation are just boxes that don't link anywhere, but I'm basing the implementation off of the&amp;nbsp;pattern I learned at the DevSummit.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080"&gt;esriConfig.apiKey = import.meta.env.VITE_KEY&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;In my .env file is the long string that you can only see once when you generate the key and have to copy somewhere so you don't lose it.&lt;/P&gt;&lt;P&gt;Has anyone else ever run into this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Feb 2026 17:41:06 GMT</pubDate>
    <dc:creator>MichelleStuart</dc:creator>
    <dc:date>2026-02-19T17:41:06Z</dc:date>
    <item>
      <title>Using API Key causes all public layers to be inaccessible</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-api-key-causes-all-public-layers-to-be/m-p/1685264#M88149</link>
      <description>&lt;P&gt;I hope everyone out there is having a good week.&lt;/P&gt;&lt;P&gt;I'm developing a custom web app using the JS Maps SDK and am accessing a lot of publicly available layers throughout the app.&amp;nbsp; I want to query a rainfall database and update a rainfall layer overnight so I added an API key to allow the app to edit my publicly available rainfall layer that is stored on our AGOL.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Adding the API key to the app causes all layers to return "invalid API key".&amp;nbsp; I can't specifically provide access for the API Key to layers I don't own, like state boundaries, etc.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;&lt;SPAN class=""&gt;[esri.layers.FeatureLayer] Failed to load layer (, 19c76fabfc4-layer-24) portal item (44801dcc31aa4085b38f540ac9947f62) [request:server]: Invalid token.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if I'm implementing it correctly because all of tutorial links in the documentation are just boxes that don't link anywhere, but I'm basing the implementation off of the&amp;nbsp;pattern I learned at the DevSummit.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080"&gt;esriConfig.apiKey = import.meta.env.VITE_KEY&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;In my .env file is the long string that you can only see once when you generate the key and have to copy somewhere so you don't lose it.&lt;/P&gt;&lt;P&gt;Has anyone else ever run into this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Feb 2026 17:41:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-api-key-causes-all-public-layers-to-be/m-p/1685264#M88149</guid>
      <dc:creator>MichelleStuart</dc:creator>
      <dc:date>2026-02-19T17:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using API Key causes all public layers to be inaccessible</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-api-key-causes-all-public-layers-to-be/m-p/1685512#M88156</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/471565"&gt;@MichelleStuart&lt;/a&gt;&amp;nbsp;- try adding the apiKey directly to the FeatureLayer you want to edit (using &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#apiKey" target="_self"&gt;FeatureLayer.apiKey&lt;/A&gt;) instead of applying it globally via esriConfig.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2026 15:08:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-api-key-causes-all-public-layers-to-be/m-p/1685512#M88156</guid>
      <dc:creator>AnneFitz</dc:creator>
      <dc:date>2026-02-20T15:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Using API Key causes all public layers to be inaccessible</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-api-key-causes-all-public-layers-to-be/m-p/1685897#M88175</link>
      <description>&lt;P&gt;Thank you Anne.&amp;nbsp; I tried adding the api key directly to the feature layer.&amp;nbsp; I do like that approach.&amp;nbsp; I no longer have the global problem of all layers becoming invalid, but I'm still having problems with the API key.&lt;/P&gt;&lt;P&gt;1. If I try to run the code from my development environment with &lt;A href="http://localhost:3000" target="_blank"&gt;http://localhost:3000 &lt;/A&gt;&amp;nbsp;it says invalid key.&amp;nbsp; I did include this url in my Application Environment: Referrers section.&amp;nbsp; Are &lt;A href="http://localhost" target="_blank"&gt;http://localhost&lt;/A&gt;&amp;nbsp;urls denied regardless?&amp;nbsp; Does anyone have any tips for testing the API key in dev.&lt;BR /&gt;2. On my production server, the code runs until it gets to the point where it needs to edit the layer and then it pops up a "sign in" dialog box.&amp;nbsp; I double checked that the key has access to the feature layer and that the privileges are create,edit,update content and edit features.&amp;nbsp; I invalidated and re-created my api key to make sure I had the exact correct one copied into my .env file.&amp;nbsp; I even changed the FeatureLayer statement to use our organization's portal url.&amp;nbsp; But the sign in popup still appears and I can't even sign in because it doesn't show an option to log in with "myorganization.maps.arcgis.com".&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any troubleshooting tips or tips for working this out in a development environment?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Feb 2026 14:38:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-api-key-causes-all-public-layers-to-be/m-p/1685897#M88175</guid>
      <dc:creator>MichelleStuart</dc:creator>
      <dc:date>2026-02-23T14:38:49Z</dc:date>
    </item>
  </channel>
</rss>

