Using Tokens
When you log in to Metacloud, your identity is authenticated and you are granted a unique authorization token that allows access to your Metacloud environment. See Using Keystone Tokens for more information on tokens used in Metacloud.
A token has a life span that allows enough time for internal services to complete tasks. You can see the expiry time by viewing your token at the command line.
To display your token information:
$ openstack token issue
+------------+--------------------------+
| Field | Value |
+------------+--------------------------+
| expires | 2017-04-01T19:07:32+0000 |
| id | <token> |
| project_id | <project_id> |
| user_id | <user_id> |
+------------+--------------------------+
Warning
Prevent unauthorized access by protecting your token from unnecessary disclosure.
Tokens become invalidated for the following reasons:
- The token has expired.
- The token was revoked.
- The user password changed.
- The user was deleted from the project.
- The user role changed.
- The role assignment was redefined.
Authenticating with a Token
Before you can use a service, you must authenticate against the service endpoint.
-
Retrieve and copy your token.
$ openstack token issue --format value --column id gAAAAAB...
-
Verify your token with an API request for the catalog list using token authentication and the identity endpoint URL.
$ curl -k -L -H 'Content-Type: application/json' -H 'X-Auth-Token: <TOKEN>' https://<API-AZ.METACLOUD.NET>:5000/v3/services
Note
For more information on using the curl CLI tool, see Using cURL with Metacloud.
Example: Request a list of flavors from the Compute service and show detail for a specific flavor
The response is truncated.
Request the flavor list:
$ curl -k -L -H 'Content-Type: application/json' \
-H 'X-Auth-Token: gAAAAAB' \
https://api-AZ.metacloud.net:8774/v2.1/d5a02...a/flavors
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3801 100 3801 0 0 2794 0 0:00:01 0:00:01 --:--:-- 2794
{
"flavors" : [
{
"id" : "1",
"name" : "m1.tiny",
"links" : [
{
"href" : "http://api-AZ.metacloud.net:8774/v2.1/d5a02...a/flavors/1",
"rel" : "self"
},
{
"rel" : "bookmark",
"href" : "http://api-AZ.metacloud.net:8774/d5a02...a/flavors/1"
}
]
},
{
"id" : "2",
"name" : "m1.small",
"links" : [
{
"href" : "http://api-AZ.metacloud.net:8774/v2.1/d5a02...a/flavors/2",
"rel" : "self"
},
{
"href" : "http://api-AZ.metacloud.net:8774/d5a02...a/flavors/2",
"rel" : "bookmark"
}
]
},
...
Request the details for flavor with id=1
:
$ curl -k -L -H 'Content-Type: application/json' \
-H 'X-Auth-Token: gAAAAAB' \
https://api-AZ.metacloud.net:8774/v2.1/d5a02...a/flavors/1
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 462 100 462 0 0 191 0 0:00:02 0:00:02 --:--:-- 191
{
"flavor" : {
"id" : "1",
"disk" : 1,
"swap" : "",
"OS-FLV-EXT-DATA:ephemeral" : 0,
"rxtx_factor" : 1,
"links" : [
{
"href" : "http://api-AZ.metacloud.net:8774/v2.1/d5a02...a/flavors/1",
"rel" : "self"
},
{
"href" : "http://api-AZ.metacloud.net:8774/d5a02...a/flavors/1",
"rel" : "bookmark"
}
],
"ram" : 512,
"OS-FLV-DISABLED:disabled" : false,
"os-flavor-access:is_public" : true,
"name" : "m1.tiny",
"vcpus" : 1
}
}