Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 -k -X 'POST' -v 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 .access.token.id)
$ echo $my_token
c9d99ae09f974002976cff766d749f48

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'

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 -k -X 'POST' -v -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 .access.token.id)
$ echo $my_token
c9d99ae09f974002976cff766d749f48

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'

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 .access.token.id)
$ echo $my_token
c9d99ae09f974002976cff766d749f48

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).