Ask Your Question

How to generate a token from Keystone for ceilometer

asked 2015-02-04 10:29:58 -0500

anonymous user


Hi, I am trying to generate a token from keystone in order to use it for ceilometer. The token I got from keystone does not work. the curl command always returns 401. any one can provide me with correct way to get the token. I used the following curl command to get the token

curl -k -X 'POST' -v http://host:5000/v2.0/tokens -d '{"auth":{"passwordCredentials":{"username": "admin", "password":"password"}, "tenantName":"admin"}}' -H 'Content-type: application/json'

and then I use the following curl command to access the ceilometer

curl -k -X 'GET' -v http://host:8777/v2.0/resources -H 'X-Auth-Token":TokenFromPreviousCall'' -H 'Content-type: application/json' -H 'Accept: application/json'

the command returns "Authentication required"


edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2015-02-05 09:00:03 -0500

3ahed gravatar image

Hi larsks,

thank you for your answer. This actually what I am trying to , I am extracting the token from the curl output and then using it in the ceilometer curl command. The problem that the the generated token does not work with ceilometer even though it works for Nova, Heat and others

edit flag offensive delete link more

answered 2015-02-04 12:29:14 -0500

larsks gravatar image

updated 2015-02-04 12:32:00 -0500

You may already know this, but it wasn't clear from your question. So, with apologies if this doesn't help:

Your first request does not return a token...that is, it does not return only a token. Take a look at what you get back from keystone. When you run:

$ curl -XPOST http://host:5000/v2.0/tokens -d '...' -H 'Content-type: application/json'

You get back a JSON-encoded response that includes a complete service catalog, various metadata about the admin user, and a token. So you want to do something like:

$ my_token=$(
    curl -k -X 'POST' -v http://host:5000/v2.0/tokens -d '...' \
    -H 'Content-type: application/json'  | jq -r
$ echo $my_token

Here I'm using the jq command to extract the relevant field from the JSON response.

Now that we actually have a token, we can use it in requests:

$ curl  http://localhost:8774/v2/95d9bbd9b446438a89a353d8adb60704/servers \
  -H "X-Auth-Token: $my_token" \
  -H 'Content-type: application/json' \
  -H 'Accept: application/json'
  "servers": [
      "name": "example",
      "links": [
          "rel": "self",
          "href": "http://localhost:8774/v2/95d9bbd9b446438a89a353d8adb60704/servers/a63af3a3-f082-4dd3-8dcf-e97959f5fe62"
          "rel": "bookmark",
          "href": "http://localhost:8774/95d9bbd9b446438a89a353d8adb60704/servers/a63af3a3-f082-4dd3-8dcf-e97959f5fe62"
      "id": "a63af3a3-f082-4dd3-8dcf-e97959f5fe62"

(I'm using Nova here instead of Ceilometer because I don't have a functioning Ceilometer install handy).

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2015-02-04 10:28:52 -0500

Seen: 1,289 times

Last updated: Feb 04 '15