mirror of
https://github.com/opencultureconsulting/orcli.git
synced 2025-03-30 00:00:52 +01:00
16 lines
526 B
Bash
16 lines
526 B
Bash
# get CSRF token (introduced in OpenRefine 3.3)
|
|
# shellcheck shell=bash
|
|
function get_csrf() {
|
|
local response
|
|
if ! response="$(curl -fs "${OPENREFINE_URL}/command/core/get-csrf-token")"; then
|
|
if ! response="$(curl -fs "${OPENREFINE_URL}/command/core/get-version")"; then
|
|
error "no OpenRefine reachable/running at ${OPENREFINE_URL}"
|
|
fi
|
|
else
|
|
if ! [[ "${response}" == '{"token":"'* ]]; then
|
|
error "getting CSRF token failed!"
|
|
fi
|
|
echo "?csrf_token=$(echo "$response" | cut -d \" -f 4)"
|
|
fi
|
|
}
|