Select to view content in your preferred language

498 Invalid Token error with esriConfig.apiKey

223
3
Jump to solution
07-24-2024 10:47 AM
WebDevelopers
New Contributor II

Hi, 

I am trying to change my TypeScript app that uses the JS SDK version 4.24 to use one of the new API keys, since its previous API Key is now legacy. I haven't changed anything except the API key, and now I get `498 Invalid Token` on every request.

I also tried the advice from this post and used my new API key in the suggested tutorial in the documentation. It doesn't work there either, but my old legacy API key does. 

Any ideas? Thanks in advance.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
WebDevelopers
New Contributor II

I believe it was created with an Esri Location Platform account. I did finally get the base map working by adding updating the referers I set on the key, but I still could not get the feature layers to load.

I finally tried adding `?f=pjson` to the feature layer URL, and then it worked. I then tried it again without the extra parameter, and it loaded. So I'm not sure why it required it to work or why it then worked when I removed the parameter. 🤔

But I have a functioning map now. Thank you for reaching out anyways!

Molly

View solution in original post

0 Kudos
3 Replies
WebDevelopers
New Contributor II

oops forgot to show part of my code

import esriConfig from '@arcgis/core/config';
import Map                          from '@arcgis/core/Map';
import MapView                      from '@arcgis/core/views/MapView';

esriConfig.apiKey = "xyzxy";
//creates the map
const map = new Map({
  basemap: "arcgis-light-gray", // Basemap layer service
});

//creates the MapView
const view = new MapView({
  map: map,
  center: [-98.0932, 38.232], // Longitude, latitude
  zoom: 4, // Zoom level
  container: 'viewDiv', // Div element
  popup: {
      autoOpenEnabled: false
  }
});

 

0 Kudos
JamesIng
Occasional Contributor

Can you just confirm what you used to create the legacy and the new API key?

There's still a bit of confusion about the API keys - was the new one generated from a Esri Location Platform account?

James from www.landkind.com
0 Kudos
WebDevelopers
New Contributor II

I believe it was created with an Esri Location Platform account. I did finally get the base map working by adding updating the referers I set on the key, but I still could not get the feature layers to load.

I finally tried adding `?f=pjson` to the feature layer URL, and then it worked. I then tried it again without the extra parameter, and it loaded. So I'm not sure why it required it to work or why it then worked when I removed the parameter. 🤔

But I have a functioning map now. Thank you for reaching out anyways!

Molly

0 Kudos