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
  • Select an option

  • Save bufordtaylor/2cd615f55724173dee246bf79653534d to your computer and use it in GitHub Desktop.

Select an option

Save bufordtaylor/2cd615f55724173dee246bf79653534d to your computer and use it in GitHub Desktop.

Revisions

  1. @ericboehs ericboehs created this gist Oct 25, 2016.
    25 changes: 25 additions & 0 deletions -
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    #! /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>'