I’m sure we all hope our sites will survive longer than one Super Bowl - but can we create a token for more than a year? Since the ArcGIS for Server Long Token request GUI really just helps the user populate and submit a REST request, why not just submit our own in its place with a longer Expiration setting?!
Check your configuration:
The ArcGIS for Server long token request is straight forward, but there is one catch (there always is): ArcGIS for Server has a maximum lifespan of long-lived tokens (this is a good thing). Even better - this is configurable! To set the maximum length for all long tokens, just log into ArcGIS for Server: Manager > Security > Settings, and you can set the length of time both the short and long tokens.
The long token lifespan is set in number of days, so for this example, we will set the number to 3654 to cover 10 years (to account for leap years and some rounding). Once the setting is updated, we can start making our longer token requests.
Generate the Token:
With the username, password, and HTTP referer site information ready to go, you can now make the token request by opening your web browser and typing a URL:
You might notice the expiration date doesn’t look the same as the config setting. While the config setting is in days, the token expiration parameter is in minutes. Once complete, a successful request will return a new token in your browser window. Copy this token to your Proxy configuration or JS file and you are off to the races. Might be a good idea to put a reminder in your 2024 calendar to update the token just in case, hopefully you aren’t already busy that day.