Hello folks,
Can anyone give me a clue how to access token using ArcGIS Python API?
I believe a token was generated when instantiating the GIS class as follows:
from arcgis.gis import GIS
gis=GIS(url="https://...",username="",password="")
I thought the token should be stored somewhere in the gis object, I looked up and down the list of properties and methods but nowhere can I find it.
Any advices and suggestions are highly appreciated.
Thanks
Simo
Solved! Go to Solution.
Hi Simo,
Yes you can find this with the following:
import arcgis
from arcgis.gis import GIS
gis = GIS("https://www.arcgis.com", "jskinner_CountySandbox", "*****")
token = gis._con.token
print(token)
Hi Simo,
Yes you can find this with the following:
import arcgis
from arcgis.gis import GIS
gis = GIS("https://www.arcgis.com", "jskinner_CountySandbox", "*****")
token = gis._con.token
print(token)
Hi Jake,
That works! Thanks a lot.
Simo
Hi Simo,
Would you mind sharing why you need access to the token though? Is there something in the API or your workflow that needs access to this token?
Thanks,
Rohit
Hi Rohit,
I am migrating some code built roughly 3 years ago using ArcREST. In one piece of the code, I need to download the data in the feature service(create Replica) and save the data in a local database.
As you know, the replica will be stored in AGO organization as the following:
To download the zip file and unzip it, I need a token to access AGO organization. This was required in my old code, and I am doing a like for like migration at the moment.
Hope this explains it.
Cheers,
Simo
Hi Simo,
Just an FYI, you can use the following tool to download your data:
Thank you Jake.
@RohitSingh2 are there any plans to add the ability to access & download replicas directly through the Python API? I am running into this same issue as @simoxu . The Python API can get us so close, but then to need to use requests to get the path to the output is a bit disappointing. The API has spoiled us by making most of these actions so easy!
I know this is an old post, but I'm wondering if there is a newer convention for accessing the authentication token? I've been using:
gis = GIS("home")
print("Token: " + str(gis._con.token))
which worked up until our org updated to 3.2 from 2.9, but doesn't work anymore - gis._con.token now returns 'None', whereas previously would return the token string.
Try this, you will have to import the arcpy module,