2022-03-25 11:16:02 +01:00
|
|
|
# get CSRF token (introduced in OpenRefine 3.3)
|
2022-04-04 20:36:03 +00:00
|
|
|
# shellcheck shell=bash
|
2022-03-25 22:02:28 +00:00
|
|
|
function get_csrf() {
|
2022-04-12 10:54:16 +00:00
|
|
|
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
|
2022-03-25 22:02:28 +00:00
|
|
|
if ! [[ "${response}" == '{"token":"'* ]]; then
|
|
|
|
error "getting CSRF token failed!"
|
|
|
|
fi
|
|
|
|
echo "?csrf_token=$(echo "$response" | cut -d \" -f 4)"
|
2022-03-25 11:16:02 +01:00
|
|
|
fi
|
|
|
|
}
|