I am attempting to make a call against a FeatureLayer:https://services.arcgis.com/4Y5FNypV9g2Wgf92/ArcGIS/rest/services/mobilehomes07232021/FeatureServer/0/query?where=ObjectId%3E0&f=pjson&token=<token>
I can generate a token using python:import requeststokenurl = "https://larimer.maps.arcgis.com/sharing/generateToken/"data = {'f':'json','username':'username','password':'password','client':'referrer'}r = requests.post(tokenurl, data=data)return r.json()When I attempt to make the service call above I get the 498, invalid token error.I've tried this with token url set to our portal home (as above) and https://www.arcgis.com/sharing/generateToken. both tokens still fail to make the call.
Any help would be greatly appreciated.
Hi @GreggTurnbull - taking a second look it looks like you're missing the referer parameter from your data dictionary since you have client:referer. If you add 'referer: https://larimer.maps.arcgis.com' to data{} I expect this will work.
Also I think you may need to spell referer with one 'r' to specify the right parameter: https://developers.arcgis.com/rest/users-groups-and-items/generate-token.htm
Thanks,
-Peter
Hi @GreggTurnbull do you see the same result from https://www.arcgis.com/sharing/rest/generateToken - it looks like the /rest portion was omitted from the URLs.
Good morning Peter - It appears it works without the rest sub as well, but I reran the call:https://www.arcgis.com/sharing/rest/generateToken/?f=json // along with credentials in the body, received an updated token,Made the call:https://services.arcgis.com/4Y5FNypV9g2Wgf92/ArcGIS/rest/services/mobilehomes07232021/FeatureServer/0/query?where=OBJECTID+%3E+0&f=pjson&token=<updated_token>And still receive:{"error" :{"code" : 498,"message" : "Invalid token.","details" : ["Invalid token."]}}Am I generating the token on the right server, I've tried: www.arcgis.com and our portal larimer.maps.arcgis.com.Again thank you for the insights.
That was it Peter - did have one more hiccup as I had to remove the reference to client=requestip in the token generation step, client should be set to referer .. or omitted. Cheers and Thank you!
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.