I am trying to use the ArcGIS API for Python (Python 3.9) to access admin capabilities of an unfederated ArcGIS (10.6.1) Site. The site is comprised of a multimachine deployment behind a single web adaptor. The site's web adaptor and associated AGS machines also sit behind a reverse proxy server.
This is my Python code to get a Server object:
from arcgis.gis.server import Server
ags_url = 'https://webadaptor.domain.org/arcgis/admin'
server = Server(url=ags_url, username=user, password=password, verify_cert=False)
The specific error that is blocking me is:
"Unauthorized access. Token not found. You can generate a token using the 'generateToken' operation."
I am passing valid ArcGIS Server credentials. I have also tried passing the '/arcgis/admin/generateToken' appended url to tokenurl and token_url as parameters (the docs/forum usage seems to vary)
In a browser, if I hit the generateToken endpoint (via html) with the credentials and the 'Request IP' <Client> parameter, I seem to receive a valid token:
JSON response:
{
"token": "blahblahblalyjfkutrk8htdkhg-khfu4twujt73g0irsdkgjh",
"expires": "1698816744485"
}
Accordingly, I can access the admin endpoint and do various admin things from my machine in a browser using the same credentials.
In Python, I can successfully create a server object with the inputs stated, but it seems no administrative privileges are granted. The privileged properties return a stack trace error in my IDE. I can see the server version, etc. & ServiceDirectory of the site but nothing else.
I suspect that the reverse proxy server is somehow contributing to the token error, but I am at a loss as to how to rectify it.
How do I get a token to the API so that I can administer the site programmatically?