Here is a little utility I’ve worked up while working with the Openstack Keystone code.
To extract the token out of the JSON, use the following pyton script
#!/usr/bin/python from sys import stdin import json print json.load(stdin)['access']['token']['id']
Which I save in ~/bin/extract_keystone_id.py
Here’s the Curl to fetch a token from Keystone, assuming you ‘ve loaded up the sample data from the unit tests:
curl -v -H "Content-Type:application/json" -s -H "Accept:applicaton/json" -d '{"auth":{"passwordCredentials":{"userId":"foo", "password":"foo2"} ,"tenantName":"bar"}}' -X POST http://0.0.0.0:35357/v2.0/tokens | ~/bin/extract_keystone_id.py