Skip to content

Instantly share code, notes, and snippets.

@lawrencejones
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lawrencejones/10305472 to your computer and use it in GitHub Desktop.
Save lawrencejones/10305472 to your computer and use it in GitHub Desktop.
Example of how to pull data from new cate api.
#!/bin/sh
echo "Enter college login:"
read user
echo "Enter password:"
read -s pass; echo
creds="{\"user\":\"$user\",\"pass\":\"$pass\"}"
# Pull JSON { token: <token> }
tokenJson=$(curl -s -X POST -H "Content-Type: application/json" \
-d $creds \
-k 'https://doc-exams.herokuapp.com/authenticate')
# Extract token
token=$(coffee -e "console.log JSON.parse('$tokenJson').token")
echo "Got token! {$token}"
# Scrape dashboard
curl -X GET -H "Content-Type: application/json" \
-H "Authorization: Bearer $token" \
-k 'https://doc-exams.herokuapp.com/api/dashboard'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment