Select to view content in your preferred language

Token for URL

1114
5
02-28-2023 05:48 PM
forestknutsen1
MVP Alum

We have an OMS (outage management system), Pragma, that we want to consume secure Esri services. They have a URL with a token on the end in their config file. They application will then use this token for each call the to the Esri service.

So, the URL would look something like :

"https://our-server/server/rest/services/Testing/OMS/MapServer/tile/{0}/{2}/{1}/256/png8?token="

How do I go about creating this token?

0 Kudos
5 Replies
Mahdi_Ch
Regular Contributor

I never used that service and not sure about the language. But generally if  I remember correctly, when you have an ArcGIS organizational subscription or an ArcGIS Enterprise license, when you start the session the token is already generated and by using the following code (in Python) on ArcGISPro you can get your token. (not sure about other licenses and online version) 

import arcpy
# return a dictionary with token and other stuff
token = arcpy.GetSigninToken()
if token is not None:
    print(token.keys()) # keys of that dictionary

you can pass your token as token['token'] to the above-mentioned link like this: 

f"https://our-server/server/rest/services/Testing/OMS/MapServer/tile/{0}/{2}/{1}/256/png8?token={ toke..."

Just remember once you added the token you don't want to share that link online.

 

0 Kudos
forestknutsen1
MVP Alum

Thanks for the feedback. Is there not a way to get it from the Portal Admin Site.

0 Kudos
TonyContreras_Frisco_TX
Frequent Contributor

If the server is federated with ArcGIS Portal, see the documentation here.

If it is standalone, check here.

forestknutsen1
MVP Alum

@TonyContreras_Frisco_TX  Thanks! That works. Any idea how I get it to last longer then two weeks?

0 Kudos
TonyContreras_Frisco_TX
Frequent Contributor

You're welcome. I think that 15 days is the max expiration for Portal, which cannot be changed. requests for anything beyond 15 will fail, according to the documentation.

If it is a standalone server, you can modify the Token Configuration to set the Long Timeout (Max timeout length in minutes) using the REST Admin API