I'm just starting with MapLibre and ESRI, and can't get it to recognize my api key.
My api key has basemap and basemap styles privileges.
With the simple tutorial code
apiKey = '<api key>';
const map = new maplibregl.Map({
container: "map", // the id of the div element
zoom: 2, // starting zoom
center: [-20, 30] // starting location [longitude, latitude]
});
const basemapStyle = maplibreArcGIS.BasemapStyle.applyStyle(map, {
style: "arcgis/outdoor",
token: apiKey
});
It generates url
https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/styles/arcgis/outdoor?f=json&echoToken=false&token=AAPT
But returns 401 / invalid_token error. The key is valid. Any ideas on how to debug this?
@hess8 it really looks like your API key is no good. Check your settings and verify you have the required privilages, expiration date is in the future, and if you have any referrers set to make sure they match your origin.
If I run your URL above with my API key the service responds with 200, so you can use this technique to test your api key
If you do not get it work work can you post the server response JSON here it might provide additional information.