Posted on
07-11-2019
01:36 PM
- last edited on
03-04-2025
02:57 AM
by
kh-richa_mig
Hello,
Using PAW (a product similar to Postman), I setup GET and Post requests to my JAMF instance using Classic API.
NowI want to use Universal API and I an confused how to use Authentication tokens.
I am kind of a newbie and would appreciate some help.
Thanks
steven
Posted on 07-11-2019 10:42 PM
Here is an example on how to update the check-in settings, make sure you have jq
installed for parsing the json
output:
#!/bin/bash
credentials="dXNlcm5hbWU6cGFzc3dvcmQ="
jps="https://jps.example.com"
uapi_token=$(curl -s -H "Content-Type: application/json" -H "Authorization: Basic ${credentials}" -X POST "${jps}/uapi/auth/tokens" | jq -r '.token')
curl -s -H "Authorization: Bearer ${uapi_token}" -H "Content-Type: application/json" -X PUT --data @- "${jps}/uapi/v1/check-in" <<EOF
{
"checkInFrequency": 15,
"isCreateHooks": true,
"isHookLog": true,
"isHookPolicies": true,
"isHookHideRestore": true,
"isHookMCX": false,
"isBackgroundHooks": true,
"isHookDisplayStatus": true,
"isCreateStartupScript": true,
"isStartupLog": true,
"isStartupPolicies": true,
"isStartupSSH": true,
"isStartupMCX": false,
"isEnableLocalConfigurationProfiles": true
}
EOF
The credentials variable is a Base64 encoded username and password string:
printf "username:password" | iconv -t ISO-8859-1 | base64 -i -