Running ArcGIS Pro 2.8 and ArcGIS Enterprise 10.9
This script should retrieve a token from an active Portal connection in ArcGIS Pro.
from arcgis.gis import GIS
# Get a Token
portalURL = arcpy.GetActivePortalURL()
token = arcpy.GetSigninToken()
if token is not None:
token = (token['token'])
gis = GIS(portalURL, token = token, verify_cert=False)
print(token)
else:
print('Fail.')
Line 8 fails with an invalid Token error. I can print the token and confirm it's valid. Any idea how I can use the token to connect to the GIS?
Exception: Invalid token.
(Error Code: 498)
Solved! Go to Solution.
line 8 is a enclosed in ( ) ... (token['token'])
GetSigninToken—ArcGIS Pro | Documentation
try token['token'] without the ( ) ... just in case it matters on the receiving end (although it shouldn't be a tuple)
line 8 is a enclosed in ( ) ... (token['token'])
GetSigninToken—ArcGIS Pro | Documentation
try token['token'] without the ( ) ... just in case it matters on the receiving end (although it shouldn't be a tuple)