yonghah / esri2sf

Scrape features from ArcGIS Server REST API and create simple features dataframe
Other
137 stars 37 forks source link

Token Url should use public generateToken instead of admin generateToken #44

Closed farleyklotz closed 2 years ago

farleyklotz commented 2 years ago

This code is using the admin location to grab a Token. ERSI ArcGIS Online and other services use the 'public' url to get a token. On a secured server, the admin token url may not be available, but I think the 'public' one always is. The public one is at: "arcgis/tokens/generateToken" instead of "arcgis/admin/generateToken" as per: https://developers.arcgis.com/rest/services-reference/enterprise/generate-token.htm

Also, we can get iformation from the server info url, even on a server where directory services is disabled: https://developers.arcgis.com/rest/services-reference/enterprise/server-info.htm

https://my.host.com/instance_name/rest/info?f=pjson

A json return looks like:

{
currentVersion: 10.61,
fullVersion: "10.6.1",
soapUrl: "https://geo.stantec.com/arcgis/services",
secureSoapUrl: null,
authInfo: {
    isTokenBasedSecurity: true,
    tokenServicesUrl: "https://geo.stantec.com/arcgis/tokens/",
    shortLivedTokenValidity: 120
    }
}

This info will be good for checking the intial validity.