Last active
February 9, 2023 15:05
-
-
Save stefansundin/ecf51b0dad7fee535df0d0f385f86647 to your computer and use it in GitHub Desktop.
Download all of your Team's custom Slack emojis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eo pipefail | |
# Log in to Slack in a web browser and open the network tools to inspect the traffic. | |
# Filter the requests with "/api/" and pick one to inspect. | |
# You need the xoxc token from the request body, and a copy of the cookies. It is the "d" cookie that is important, but you can copy all of them. Make sure that the cookie value is percent encoded! | |
# Paste the values below. | |
# You need to have curl and jq installed. | |
# You can also get the xoxc token from localStorage. Run this in the JavaScript console: | |
# Object.entries(JSON.parse(localStorage.localConfig_v2)["teams"]).reduce((o,e) => Object.assign(o, { [e[1]["name"]]: e[1]["token"] }), {}) | |
SLACK_TOKEN="xoxc-...." | |
COOKIES="d=...." | |
data=$(curl -q -sS -b "$COOKIES" "https://slack.com/api/emoji.list?token=$SLACK_TOKEN") | |
if echo "$data" | jq -e '.error?' > /dev/null; then | |
echo "$data" | |
exit 1 | |
fi | |
echo "$data" > data.json | |
echo "$data" | jq -Mr '.emoji | to_entries | .[] | select(.value | startswith("http")) | "\(.key) \(.value)"' | sort | while read name url; do | |
fn="$name.${url##*.}" | |
[[ -f "$fn" ]] && continue | |
echo "$fn" | |
curl -q -sS -o "$fn" "$url" | |
done |
I updated the script and added better instructions. Let me know if anything isn't working.
Worked perfectly for me. Thank you!
This worked great for me, thank you!
I get an
{
"ok": false,
"error": "invalid_auth"
}
for:
curl -q -sS -b "$COOKIES" "https://slack.com/api/emoji.list?token=$SLACK_TOKEN"
I used the sniffed xoxc (q=JSON.parse(localStorage.localConfig_v2)["teams"]; q[Object.keys(q)[0]]["token"]) and the d cookie but no joy.
Any hints?
@donnels I suspect your cookie value is not encoded. It does seem like curl needs the data to already be percent encoded. I'll update the instructions to note this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://api.slack.com/changelog/2020-02-legacy-test-token-creation-to-retire