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

1382
1
Jump to solution
12-13-2021 02:12 PM
tigerwoulds
Occasional Contributor III

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)

 

 

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