#Name: Generate a token from ArcGIS Server using python
#Author: Bryan McIntosh
#Description: Python script to generate a token from ArcGIS Server for use with secure map services.
# This sample uses the 'requests' module (https://pypi.python.org/pypi/requests/2.7.0)
import requests
params = {'username': 'USERNAME', 'password': 'PASSWORD', 'client': 'requestip', 'f': 'json'}
request = requests.post('https://YOUR.SITE.com/arcgis/tokens',params=params)
response = request.json()
myToken = response["token"]