Hello,
I had been using Pro 2.7, but recently upgraded to 3.2. The code I had been using with 2.7 worked fine, but doesn't seem to work with 3.2 I'm connecting to GIS() using Built-In login, as described here:
Connect to ArcGIS Online using a built-in account > Connecting through ArcGIS Pro
https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/
To connect I have been using:
gis = GIS('pro'), or in some cases: gis = GIS('home')
and to get the token, I've been using:
auth_token = gis._con.token
which I found referenced in this community post, and elsewhere:
https://community.esri.com/t5/arcgis-api-for-python-questions/get-the-token-using-arcgis-python-api/...
But these methods don't work anymore, and do not return a token:
gis = GIS('pro')
print("Logged in as: " + gis.properties.user.username)
print('token='+str(gis._con.token))
Returns:
Logged in as: myUsername
token=None
gis = GIS('home')
print("Logged in as: " + gis.properties.user.username)
print('token='+str(gis._con.token))
Returns:
Logged in as: myUsername
token=None
Can anyone offer any insight?
What do you need the token for? Operations on the ArcGIS API for python use the GIS instance as authentication for secure resources.
If you're trying to use the token for the REST API, the API for python can do pretty much all the operations from the REST API (GIS API for python is a wrapper of the REST API).
I have a script to create a Replica that checks for valid token and if it's expired, gets a new one. My code worked using the authentication and token access method I described, up until a couple of weeks ago, after we upgraded from 2.7 to 3.2.
My org doesn't use named users for login, so username/password isn't an option.