To authenticate, you issue a POST /tokens request to the appropriate Rackspace Cloud Identity Service endpoint.
In the request body, supply one of the following sets of credentials:
user name and password
user name and API key
Your username and password are the ones that you use to log into the Rackspace Cloud control panel.
To obtain your API key, log into http://mycloud.rackspace.com, click your username, and select API Keys to get your key.
To authenticate with cURL:
Get an authentication token and a service catalog with a list of endpoints.
Use one of the following cURL commands to authenticate to the US Identity endpoint:
Example 4. Authenticate with Username and Password: JSON Request
$ curl -s https://identity.api.rackspacecloud.com/v2.0/tokens -X 'POST' \ -d '{"auth":{"passwordCredentials":{"username":"theUserName", "password":"thePassword"}}}' \ -H "Content-Type: application/json" | python -m json.toolExample 5. Authenticate with Username and API Key: JSON Request
$ curl -s https://identity.api.rackspacecloud.com/v2.0/tokens -X 'POST' \ -d '{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"theUserName", "apiKey":"0000000000000000000"}}}' \ -H "Content-Type: application/json" | python -m json.tool![[Note]](/servers-v2-cs-gettingstarted/common/images/admon/note.png)
Note For information about the json.tool, see json.tool.
In response to valid credentials, your request returns an authentication token and a service catalog with the endpoints to request services.
Do not include explicit API endpoints in your scripts and applications. Instead, find the endpoint for your service and region.
The following output shows a partial authentication response in JSON format:
Example 6. Authenticate: JSON Response
{ "access": { "serviceCatalog": [ { "endpoints": [ { "internalURL": "https://snet-storage101.dfw1.clouddrive.com/v1/MossoCloudFS_530f8649-324c-499c-a075-2195854d52a7", "publicURL": "https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_530f8649-324c-499c-a075-2195854d52a7", "region": "DFW", "tenantId": "MossoCloudFS_530f8649-324c-499c-a075-2195854d52a7" }, { "internalURL": "https://snet-storage101.ord1.clouddrive.com/v1/MossoCloudFS_530f8649-324c-499c-a075-2195854d52a7", "publicURL": "https://storage101.ord1.clouddrive.com/v1/MossoCloudFS_530f8649-324c-499c-a075-2195854d52a7", "region": "ORD", "tenantId": "MossoCloudFS_530f8649-324c-499c-a075-2195854d52a7" } ], "name": "cloudFiles", "type": "object-store" }, { "endpoints": [ { "publicURL": "https://servers.api.rackspacecloud.com/v1.0/010101", "tenantId": "010101", "versionId": "1.0", "versionInfo": "https://servers.api.rackspacecloud.com/v1.0", "versionList": "https://servers.api.rackspacecloud.com/" } ], "name": "cloudServers", "type": "compute" }, ... { "endpoints": [
{
"publicURL": "https://dfw.servers.api.rackspacecloud.com/v2/010101",
"region": "DFW",
"tenantId": "010101",
"versionId": "2",
"versionInfo": "https://dfw.servers.api.rackspacecloud.com/v2",
"versionList": "https://dfw.servers.api.rackspacecloud.com/"
},
{
"publicURL": "https://ord.servers.api.rackspacecloud.com/v2/010101",
"region": "ORD",
"tenantId": "010101",
"versionId": "2",
"versionInfo": "https://ord.servers.api.rackspacecloud.com/v2",
"versionList": "https://ord.servers.api.rackspacecloud.com/"
}
],
"name": "cloudServersOpenStack",
"type": "compute"
},
...
],
"token": {
"expires": "2012-09-14T15:11:57.585-05:00",
"id": "858fb4c2-bf15-4dac-917d-8ec750ae9baa",
"tenant": {
"id": "010101",
"name": "010101"
}
},
"user": {
"RAX-AUTH:defaultRegion": "DFW",
"id": "170454",
"name": "MyRackspaceAcct",
"roles": [
{
"description": "User Admin Role.",
"id": "3",
"name": "identity:user-admin"
}
]
}
}
}
Successful authentication returns the following information:

Endpoints to request Rackspace Cloud services. Appears in the
endpointselement in theserviceCatalogelement.Endpoints information includes the public URL, which is the endpoint that you use to access the service, region, tenant ID, and version information.

Tenant ID. Appears in the
tenantIdfield in theendpointselement. Also known as the account number.You include the tenant ID in the endpoint URL when you call a Cloud service.
In the following example, you export the tenant ID,
010101, to theaccountenvironment variable and the authentication token to thetokenenvironment variable. Then, you issue a cURL command, as follows:$ export account="010101" $ export token="00000000-0000-0000-000000000000" $ curl -s https://dfw.servers.api.rackspacecloud.com/v2/$account/images/detail \ -H "X-Auth-Token: $token" | python -m json.tool
The name of the service. Appears in the
namefield.Locate the correct service name in the service catalog, as follows:
First generation Cloud Servers. Named
cloudServersin the catalog.If you use the authentication token to access this service, you can view and perform first generation Cloud Servers API operations against your first generation Cloud Servers.
Cloud Networks or next generation Cloud Servers. Named
cloudServersOpenStackin the catalog.To access the Cloud Networks or next generation Cloud Servers service, use the
publicURLvalue for thecloudServersOpenStackservice.Might show multiple endpoints to enable regional choice. Select the appropriate endpoint for the region that you want to interact with by examining the
regionfield.If you use the authentication token to access this service, you can view and perform Cloud Networks or next generation Cloud Servers API operations against your next generation Cloud Servers. To complete Cloud Networks API operations, you must also get access to this service. To request access, click here.

Expiration date and time for authentication token. Appears in the
expiresfield in thetokenelement.After this date and time, the token is no longer valid.
This field predicts the maximum lifespan for a token, but does not guarantee that the token reaches that lifespan.
Clients are encouraged to cache a token until it expires.
Because the authentication token expires after 24 hours, you must generate a token once a day.

Authentication token. Appears in the
idfield in thetokenelement.You pass the authentication token in the
X-Auth-Tokenheader each time that you send a request to a service.In the following example, you export the tenant ID,
010101, to theaccountenvironment variable. You also export the authentication token,00000000-0000-0000-000000000000, to thetokenenvironment variable. Then, you issue a cURL command, as follows:$ export account="010101" $ export token="00000000-0000-0000-000000000000" $ curl -s https://dfw.servers.api.rackspacecloud.com/v2/$account/images/detail \ -H "X-Auth-Token: $token" | python -m json.toolCopy the values in the
publicURLandtenantIdfields for thecloudServersOpenStackservice for your region.Copy the authentication token from the
idfield in thetokenelement.In the next step, you set environment variables to these values.

