I'm attempting to authenticate to and use the Admin Geoevent API, and I'm so far failing.
Documentation on usage is sparse without examples:
Authenticating via browser works and I'm able to make API requests through there, but I want to perform this programmatically from a server.
Here are the steps to successfully using the admin API through the browser:
However doing it programmatically I am getting a 403 forbidden response. I've attempted to adapt one of the only examples of Geovent admin API authorization I've found. This example is strange as I've found no documentation anywhere about passing your API token in your HTTP headers as "GeoEventAuthorization": Using the GeoEvent Admin API with Python
My own adaptation with small tweaks fails with a 403 forbidden error, as does the original: gist:2c973bd88532376567625703fe915e9c · GitHub
Anyone else successfully make Geoevent admin API calls?
Solved! Go to Solution.
Well, this suggestion was in a comment, I thought I had already tried this but I guess I did it wrong.
Changing the token request URL from
https://myserver.org:6443/arcgis/admin/generateToken
to
https://myserver.org:6443/arcgis/tokens
Worked. Which makes me feel dumb because that's the URL I hit in my browser for manually viewing API results.
See Also: Using the GeoEvent Admin API with Python
https://community.esri.com/docs/DOC-13489-using-the-geoevent-admin-api-with-python
Well, this suggestion was in a comment, I thought I had already tried this but I guess I did it wrong.
Changing the token request URL from
https://myserver.org:6443/arcgis/admin/generateToken
to
https://myserver.org:6443/arcgis/tokens
Worked. Which makes me feel dumb because that's the URL I hit in my browser for manually viewing API results.
See Also: Using the GeoEvent Admin API with Python
https://community.esri.com/docs/DOC-13489-using-the-geoevent-admin-api-with-python
Thanks for Posting!
I was running into a similar issue while trying to write a Python script to get the status' of all the GES services and sending an alert if any were encountering errors!
I changed the Token request (as you suggested) and also found out that I had to use the server's public URL as the referer! I could get a token using 'requestip' as the 'client' value, but GES would not accept it.
def getToken ():
url = 'https://<GES local URL>:6443/arcgis/tokens/'
gesUn = '<GES UN>'
gesPass = '<GES Pass>'
params = {'username': gesUn, 'password': gesPass, 'client': 'client', 'referer': 'https://<GES Public URL>:6143/geoevent', 'f': 'pjson'}
request = requests.post(url,data=params, verify=False)
response = request.json()
myToken = response["token"]
return(myToken)
Thanks Again!
Chris