Setting XCreds Preferences with Defaults

You are here:

Both the license file and preferences for XCreds are typically set with an MDM. However, these settings are just preferences provided in the System domain and can be set manually. Below is a script to show how to set basic settings and the license file using a script.

#!/bin/bash

app_id="/Library/Preferences/com.twocanoes.xcreds.plist"

#Copy the text between <data> and </data> from the LicenseFile key and paste it between the quotes below

license_base64=""

#check to make sure are running as root to put into system domain
if [ "$(id)" != 0 ]; then 
	echo "Please use sudo"
fi

#convert license file to hex since default command doesn't understand base64
license_hex=$(echo "${license_base64}" |base64 -d|xxd -p|tr -d "\n")

#write out keys. Add keys as needed
defaults write "${app_id}" discoveryURL "https://login.microsoftonline.com/common/.well-known/openid-configuration"
defaults write "${app_id}" redirectURI "https://127.0.0.1/xcreds"
defaults write "${app_id}" scopes "profile openid email offline_access"
defaults write "${app_id}" clientID "5487c4cd-949a-402d-9eee-ae8fb696b415"

defaults write "${app_id}" "LicenseFile" -data "${license_hex}"
Tags: