If you use a token for authentication, you must obtain the user's token and add X-Auth-Token to the request message header of the service API when making an API call.
This section describes how to make an API call for token authentication.
Name |
Description |
Mandatory |
Example |
---|---|---|---|
Content-Type |
Specifies the MIME type of the request body. |
Yes |
application/json |
{ "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "password": "password", "domain": { "name": "domainname" } } } }, "scope": { "project": { "id": "project_id" } } } }
In the preceding command, replace parameter in italic with the actual values. For details, see the "Obtaining a User Token" section in the Identity and Access Management API Reference.
After the request is processed, the value of X-Subject-Token in the header is the token value.
X-Subject-Token:MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...
export Token={X-Subject-Token}
X-Subject-Token: Replace it with the token obtained in 2. An example command is as follows:
export Token=MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...