Skip to content

Instantly share code, notes, and snippets.

@tonvanbart
Created May 15, 2017 09:18
Show Gist options
  • Save tonvanbart/9d42274061e72fd771b2c12d2397c965 to your computer and use it in GitHub Desktop.
Save tonvanbart/9d42274061e72fd771b2c12d2397c965 to your computer and use it in GitHub Desktop.
Quick reference on how to extract XSRF token cookie value and store it for later use in a bash script.
#!/bin/sh
if [ "$#" -ne 1 ]; then
echo Usage is: $0 base-url where base-url is up to and including gateway/api
exit 0
fi
XSRF_COOKIE="$(curl $1/provisioning/health -I 2>/dev/null | grep Set-Cookie | sed -e 's/^Set-Cookie: XSRF-TOKEN=\([^;]*\);\(.*\)/\1/')"
echo found cookie: $XSRF_COOKIE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment