Skip to content

Instantly share code, notes, and snippets.

@bufordtaylor
Forked from ericboehs/retrieving-mme-for-apple-caldav.sh
Created October 27, 2016 16:52
Show Gist options
  • Save bufordtaylor/2cd615f55724173dee246bf79653534d to your computer and use it in GitHub Desktop.
Save bufordtaylor/2cd615f55724173dee246bf79653534d to your computer and use it in GitHub Desktop.
#! /usr/bin/env bash
export APPLE_USER=user@example.com
export APPLE_PASS=password1
export AUTH_PLIST=$(curl -su "$APPLE_USER:$APPLE_PASS" "https://setup.icloud.com/setup/authenticate/$APPLE_USER")
export DSID=$(/usr/libexec/PlistBuddy -c "Print appleAccountInfo:dsid" /dev/stdin <<< $AUTH_PLIST)
echo $DSID
export TEMP_MME_AUTH_TOKEN=$(/usr/libexec/PlistBuddy -c "Print tokens:mmeAuthToken" /dev/stdin <<< $AUTH_PLIST)
echo $TEMP_MME_AUTH_TOKEN
# It seems this step is unnecessary as the mme auth tokens are the same
# export SETTINGS_PLIST=$(curl -su "$DSID:$TEMP_MME_AUTH_TOKEN" "https://setup.icloud.com/setup/get_account_settings")
# echo $SETTINGS_PLIST
# export MME_AUTH_TOKEN=$(/usr/libexec/PlistBuddy -c "Print tokens:mmeAuthToken" /dev/stdin <<< $SETTINGS_PLIST)
# echo $MME_AUTH_TOKEN
export MME_AUTH_TOKEN=$TEMP_MME_AUTH_TOKEN
export TOKEN=$(echo "$DSID:$MME_AUTH_TOKEN" | base64)
echo $TOKEN
curl -X PROPFIND https://p01-caldav.icloud.com -H "Depth: 1" -H "Authorization: X-MobileMe-AuthToken $TOKEN" \
--data '<d:propfind xmlns:d="DAV:"><d:prop><d:current-user-principal /></d:prop></d:propfind>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment