Authenticating to the geoevent admin api

835
2
Jump to solution
11-14-2019 03:48 PM
RolandMacDavid
New Contributor II

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:

  1. GeoEvent Server REST API documentation—Administer(10.7.1) | ArcGIS Enterprise
  2. GeoEvent Server administration—Administer(10.7.1) | ArcGIS Enterprise 

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:

  1.  Create a token here: https://myserver.org:6443/arcgis/tokens
  2. Set the restriction to "Referrer URL" with a url of https://myserver.org:6143/geoevent/admin .
  3. Then pasting the provided token here gets it working in the browser: https://myserver.org:6143/geoevent/admin/

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?

0 Kudos
1 Solution

Accepted Solutions
RolandMacDavid
New Contributor II

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

View solution in original post

2 Replies
RolandMacDavid
New Contributor II

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

ChrisSchreiber
New Contributor II

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

0 Kudos