Child pages
  • _Authenticating Service Calls

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Code Block

#The script needs the servername:portnumber, username and password respectively to work correctly.

if [[ $# -ne 3 ]] ; then
echo 'Invalid command. Please run authenticate script in following format ./authenticateCallService <servername:port> <username> <password>'
    exit 1

curl -c ~/loginRequestCookie -X POST "http://$1/$ProductAbbrevLowercase/tbl"   -D ~/firstReqHeaders > /dev/null

#The server sends a new cookie as a response to this request. Use that cookie for subsequent requests.
curl -b ~/loginRequestCookie -X POST "http://$1/$ProductAbbrevLowercase/tbl/j_security_check" -H "Context-Type: application/x-www-form-urlencoded" --data "j_username=$2&j_password=$3"  -L "http://$1/$ProductAbbrevLowercase/tbl" -c ~/loginSuccessCookie -D ~/secReqHeaders 

curl -b ~/loginSuccessCookie -X POST "http://$1/$ProductAbbrevLowercase/tbl/sparql" -G --data-urlencode "query=SELECT * WHERE{?s a <>} "  --data-urlencode "default-graph-uri=" --data "format=json" -D ~/thirdReqHeaders

#Logout when done so as not to exhaust the user limit on the license
curl -b ~/loginSuccessCookie -X POST "http://$1/$ProductAbbrevLowercase/tbl/purgeuser" -D ~/logoutReqHeaders