Invalid token error when connecting to GIS using GetSigninToken and ArcGIS Python API

424
1
Jump to solution
12-13-2021 02:12 PM
TigerWoulds
Occasional Contributor III

Running ArcGIS Pro 2.8 and ArcGIS Enterprise 10.9

I have a simple script that I need to run from ArcGIS Pro that will get a token from our Portal and use that to connect to my GIS. The user needs to signed into the Portal in ArcGIS Pro and have it set as the active portal. 

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)

 

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

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)


... sort of retired...

View solution in original post

0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor

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)


... sort of retired...
0 Kudos