Step1とStep2をスクリプトで書いてみました
最後のHTTP codeが200となれば、トークン認証が成功しています
#!/bin/sh app="pc_html5" version="0.0.1" user="dummy_user" device="pc" key="bcd151073c03b352e1ef2fd66c32209da9ca0afa" param=(`curl -s -c cookie.txt -H "X-Radiko-App: ${app}" -H "X-Radiko-App-Version: ${version}" -H "X-Radiko-User: ${user}" -H "X-Radiko-Device: ${device}" -I -L https://r adiko.jp/v2/api/auth1 | egrep -i 'X-Radiko-AuthToken:|X-Radiko-KeyLength:|X-Radiko-KeyOffset:' | sed -e 's/^.*: \([0-9a-zA-Z]\+\)/\1/i'`) authtoken=`echo -n ${param[0]} | sed -e "s/[\r\n]\+//g"` keylength=`echo -n ${param[1]} | sed -e "s/[\r\n]\+//g"` keyoffset=`echo -n ${param[2]} | sed -e "s/[\r\n]\+//g"` partialkey=`echo -n ${key:${keyoffset}:${keylength}} | base64` code=`curl -s -b cookie.txt -c cookie.txt -o /dev/null -w '%{http_code}' -H "X-Radiko-AuthToken: ${authtoken}" -H "X-Radiko-PartialKey: ${partialkey}" -H "X-Radiko-Devic e: ${device}" -H "X-Radiko-User: ${user}" -s -L https://radiko.jp/v2/api/auth2` echo "AuthToken : ${authtoken}" echo "KeyLehgth : ${keylength}" echo "KeyOffset : ${keyoffset}" echo "PartialKey: ${partialkey}" echo "HTTP code : ${code}"