Hello,
I'm hoping someone can help with this problem I ran into today. I can no longer access the authentication token using the Connect through Built-In account method, or the Connect through Pro method. Both of these methods worked for me up until today, and would return a token string accessed through gis._con.token. I can still get a token through OAuth, but I need to run scheduled scripts, unsupervised. Also, my org doesn't use Named User Authentication, so username/password isn't an option.
// This method still works, and returns a token:
gis = GIS('https:myGisPortal.maps.arcgis.com', client_id='myClientID')
print("Logged in as: " + gis.properties.user.username)
print('token='+str(gis._con.token))
Returns:
Logged in as: myUsername
token=sYzv_5rgSSiElv7...bzoR2oayAHTvuJG8
// 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
To add context, I recently upgraded from AG Pro 2.9 to 3.2. Both authentication methods gis = GIS('home') & gis = GIS('pro') would allow access to the authentication token through token=gis._con.token in AG Pro 2.9, but this does not seem to be the case anymore in 3.x. 2 coworkers tested it in their 3.2 machines and it didn't work for them, and one tested it in 3.1.2, and it didn't work there either.
I have the same problem. To clarify, I am attempting to pass Active Directory credentials to GIS() to our enterprise portal.
gis = GIS('https://portalserver.domain.com/arcgis', 'Domain\\username', 'myPassword')
I know the authentication is succeeding because if I intentionally fudge the password the script fails.
Faced the same problem today with GIS("PRO"). The solution when using arcgis pro seems to be using the following code. I also tested GIS() with a URL to arcgis enterprise with a username and password and that also works.
import arcpy
token = arcpy.GetSigninToken()
if token is not None:
print(token['token'])