Select to view content in your preferred language

Display a map in CodePen: code 498 invalid token error

347
3
Jump to solution
01-29-2025 03:12 PM
Wehara
by
Emerging Contributor

Hi everyone,

I'm running the Display a map sample in CodePen.
https://developers.arcgis.com/javascript/latest/tutorials/display-a-map/

All the code in CodePen is exactly identical to the tutorial, except the part apiKey: "YOUR_ACCESS_TOKEN" was replaced with my API key.

The API key was generated on Location Platform. Expiration date is 12/31/2025, and the referrers just contain one item which is https://codepen.io/

Error message shown in CodePen console is as follows. What could be problems with the API key, and how to fix the error?

"[esri.Basemap]" "#load()" "Failed to load basemap (title: 'Basemap', id: '194b4471ad7-basemap-0')" // [object Object]
{
"name": "request:server",
"message": "Token Invalid.",
"details": {
"url": "https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/webmaps/arcgis/topographic",
"requestOptions": {
"query": {
"language": "en",
"places": null,
"worldview": null,
"token": "AAPTxy8BH1V***********"
},
"signal": {}
},
"ssl": false,
"httpStatus": 498,
"messages": [
"The required authentication information is invalid. The token is either invalid or has expired."
],
"raw": {
"code": 498,
"message": "Token Invalid.",
"details": [
"The required authentication information is invalid. The token is either invalid or has expired."
],
"restInfoUrl": "https://basemapstyles-api.arcgis.com/arcgis/rest/info"
}
}
}

0 Kudos
1 Solution

Accepted Solutions
Sage_Wall
Esri Regular Contributor

Actually I can replicate this and it's an issue with the referer.  When I look at the request in the console that gets blocked it's getting sent from 

 
Setting the referrer to that might work
 

View solution in original post

3 Replies
Sage_Wall
Esri Regular Contributor

Hi @Wehara , When you created your API key did you assign it the location services basemap privilege? https://developers.arcgis.com/documentation/security-and-authentication/api-key-authentication/tutor....  

Sage_Wall
Esri Regular Contributor

Actually I can replicate this and it's an issue with the referer.  When I look at the request in the console that gets blocked it's getting sent from 

 
Setting the referrer to that might work
 
Wehara
by
Emerging Contributor

Hi @Sage_Wall 

Thank you very much. Update the referrer then it's ok now.

0 Kudos