You need to sign in to do that
Don't have an account?
jsawk
For everyone that's testing stuff with the command line, check out jsawk, this allows you to parse & process json from the command line. (If you're on a Mac, you can get the spidermonkey dependency via macports)
I have this script to get me an oauth token via the username password flow
curl https://login.salesforce.com/services/oauth2/token -d grant_type=password -d client_id=myClientId -d client_secret=mySecret -d username=foo@example.com -d password=myPassword -# | ./jsawk "return this.access_token"
This uses jsawk to extract the access_token value from the response json, using the shell's ` operator, its easy to stick this in a shell variable,
export SFDC_SID=`./login.sh`
You can then easily refer to your token when making curl calls to the rest API, e.g.
curl -H "Authorization: OAuth $SFDC_SID" http://na1.salesforce.com/services/data/v20.0/recent
Of course, you can use jsawk on these as well to process the response, e.g. this will show just the Ids of the records in your MRU
curl -H "Authorization: OAuth $SFDC_SID" http://na1.salesforce.com/services/data/v20.0/recent | ./jsawk "return this.Id"
Very sexy! Thanks Simon!
Jeff Douglas
Appirio, Inc.
http://blog.jeffdouglas.com
Author: The Salesforce Handbook