I was able to get the api token with the following code(actual URL and creds omitted obviously). Now on to the bookmarking. I might run into the issue that Nick had in this post Problems with Talk2M DMWeb API through system.net.httpClient and system.net.httpPost - Ignition - Inductive Automation Forum, but we’ll see shortly!
import urllib
url = "http://somebogusurl.com/API/IDP/connect/token"
payload = urllib.urlencode({
"grant_type": "password",
"username": "User",
"password": "password",
"client_id": "GrantValidatorClient"
})
try:
# Create an HttpClient instance (or use system.net.httpClient directly in Ignition 8.3+)
# For older versions, consider creating a top-level instance for reuse.
httpClient = system.net.httpClient()
#response = httpClient.post(url, data=payload) # Use data for form-urlencoded
# Or for JSON payload:
response=httpClient.post(url=url, headers={"Content-Type":"application/x-www-form-urlencoded"}, data=payload)
print response.json
except Exception as e:
print(e)