Skip to main content
Solved

Securing Planet Api Key from client in wmts requests arcgis sdk js

  • 19 July 2024
  • 1 reply
  • 76 views

I am using Arcgis sdk for js 4.xx  for my web app. My idea is to add planet basemap using wmts layer.

const planetApiKey = "myPlanetApiKey"
const activeLayerId= "mySelectedBasemap"
            const custom_params = {
              api_key: planetApiKey
            }
            const wmtsLayer = new WMTSLayer({
              url: `https://api.planet.com/basemaps/v1/mosaics/wmts?`, // url to the service
              activeLayer: {
                id: activeLayerId,
              },
              customParameters: custom_params
            });
           
            // Add the layer to the map
            map.add(wmtsLayer);

 

 this will, of course, expose my Api Key on my client side, Is there a way to hide my credentials using this approach ?,
Thanks in advance.

1 reply

Userlevel 3
Badge +5

Hey @daniel1uno, our recommendation is that you create a reverse proxy to hide your API key.  You can find a bit more information in our documentation about our tile services here. I see that you are also using the WMTS service - we recommend that you proxy the XYZ service instead. The WMTS metadata may include your API key in it, even when using a proxy service.

Reply