文档
测试

获取Token

POST
/v3/auth/tokens

接口描述

验证身份并生成Token。使用密码验证身份和作用域授权操作指定的项目、域或系统。

验证错误

| 返回码 | 描述 | | :--------: | ----- | | __Bad Request (400)__ | 身份服务未能按预期解析请求。 发生以下错误之一:<br />1. 缺少必需的属性。<br />2. 指定了不允许的属性,例如基本CRUD操作中POST请求上的ID。<br />3. 指定了意外数据类型的属性。 | | __Unauthorized (401)__ | 发生以下错误之一:<br />1. 未执行身份验证。<br />2. 指定的X-Auth-Token标头无效。3. 身份验证凭据无效。<br />4. 并非所有MFA规则都得到满足。<br />5. 指定的Openstack-Auth-Receipt标头无效 | | __Forbidden (403)__ | 身份已成功认证,但无权执行所请求的操作。| | __Not Found (404)__ | 操作失败,因为ID找不到引用的实体。 对于POST请求,可能在请求正文中而不是在资源路径中指定引用的实体。| | __Conflict (409)__ |POST或PATCH操作失败。 例如,客户尝试更新一个实体的唯一属性,该属性与同一集合中另一个实体的属性冲突。<br />或者,客户端对具有用户定义的唯一属性的集合发出两次创建操作。 例如,客户端针对用户实体的唯一的,用户定义的名称属性向POST / users请求两次。|

请求参数

参数名
类型
描述
必填
auth
object
验证体。
必填
identity
object
身份对象。
必填
methods
array
验证方法。对密码验证来说,特指“password”。
必填
password
object
密码对象,包括验证信息。
必填
user
object
用户对象。
必填
name
string
用户名。用户ID和用户名任选其一。
可选
id
string
用户ID。用户ID和用户名任选其一。
可选
password
string
用户密码。
必填
scope
object
授权范围,包括项目和域。ID足以唯一标识一个项目,但是如果通过名称指定了项目,则还必须指定项目的域,以便通过名称唯一标识该项目。 可以通过具有相同结果的域ID或名称来指定域范围。
必填
project
object
项目对象。
必填
domain
object
域。
必填
name
string
域名称。
必填
name
string
项目名称。
必填

响应参数

参数名
类型
描述
必填
X-Subject-Token
string
身份验证Token。 身份验证响应将在返回头中而不是主体中返回Token ID。
必填
token
object
Token对象
必填
is_domain
boolean
示例:false
必填
methods
array
验证方法。对密码验证来说,特指“password”。
必填
roles
array
角色对象列表
必填
id
string
示例:9fe2ff9ee4384b1894a90878d3e92bab
必填
name
string
示例:_member_
必填
expires_at
string
Token 失效时间。格式为ISO-8601。
必填
project
object
项目
必填
domain
object
必填
id
string
域id
必填
name
string
域名称。
必填
id
string
项目id。
必填
name
string
项目名称。
必填
catalog
array
程序入口目录对象。
必填
endpoints
array
程序入口列表。
必填
region_id
string
程序入口所在地ID
必填
url
string
程序入口URL
必填
region
string
程序入口所在地
必填
interface
string
程序面向接口。
必填
id
string
程序入口id。
必填
type
string
程序入口类型。
必填
id
string
程序入口id。
必填
name
string
程序入口名称。
必填
user
object
用户对象。
必填
password_expires_at
object
密码失效的时间。格式为ISO-8601。
必填
domain
object
域对象,包括代表Token作用域的域的id和名称。 仅包含在指定范围内的Token中。
必填
id
string
域id
必填
name
string
域名称
必填
id
string
用户id。
必填
name
string
用户名。
必填
audit_ids
array
一两个审计ID的列表。 审核ID是一个随机生成的唯一的URL安全字符串,可用于跟踪Token。 第一个审核ID是Token的当前审核ID。 第二个审核ID仅针对重新定义范围的Token存在,并且是该Token在重新定义范围之前的审核ID。 重新限定范围的Token是交换为相同或不同范围的另一个Token的Token。 您可以使用这些审核ID来跟踪Token或Token链在多个请求和端点中的使用,而无需将TokenID暴露给非特权用户。
必填
issued_at
string
Token 生成的时间。格式为ISO-8601。
必填

说明 / 示例

### token的使用方法 >d 在之后的接口请求中,都应该在头部带上X-Auth-Token={{token}} ### 获得后续API入口 >d 在返回值中,包含了所有不同功能的API的程序入口及其面向接口。常用为compute和network。接口为“public”。 ### 请求示例 ```json { "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "hanlp123", "password": "Dksou@2020", "domain": { "name": "Default" }, } } }, "scope": { "project": { "domain": { "name": "Default" }, "name": "hanlp" } } } } ``` ### 返回示例 ```json { "token": { "is_domain": false, "methods": [ "password" ], "roles": [ { "id": "9fe2ff9ee4384b1894a90878d3e92bab", "name": "_member_" } ], "expires_at": "2020-08-08T06:59:26.000000Z", "project": { "domain": { "id": "default", "name": "Default" }, "id": "55b657d7e83243d2badff82cf1971b24", "name": "hanlp" }, "catalog": [ { "endpoints": [ { "region_id": "RegionOne", "url": "http://192.168.10.10:8977", "region": "RegionOne", "interface": "internal", "id": "76068d76266b48789d234909176919fc" }, { "region_id": "RegionOne", "url": "http://10.20.30.40:8977", "region": "RegionOne", "interface": "public", "id": "82217576497847179248bacb4c5c658e" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8977", "region": "RegionOne", "interface": "admin", "id": "e9059cc9c28e467381fb82afa15ea627" } ], "type": "event", "id": "1deb10235a314baeb36bdb3d8b1183b2", "name": "panko" }, { "endpoints": [ { "region_id": "RegionOne", "url": "http://192.168.10.10:8889", "region": "RegionOne", "interface": "admin", "id": "7c02a494ecac41cb8eb285e0d70ad17a" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8889", "region": "RegionOne", "interface": "internal", "id": "a123cbc2981d429795b655e9e44dd593" }, { "region_id": "RegionOne", "url": "http://10.20.30.40:8889", "region": "RegionOne", "interface": "public", "id": "fe7fcb8dd2a341bf8689cad36d36f2ac" } ], "type": "rating", "id": "294b3827909541e7b9ac71372f5a5a97", "name": "cloudkitty" }, { "endpoints": [ { "region_id": "RegionOne", "url": "http://192.168.10.10:8004/v1/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "admin", "id": "1f468b3e8d3b451890630f3a647129ed" }, { "region_id": "RegionOne", "url": "http://10.20.30.40:8004/v1/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "public", "id": "3dd23ef878ff4d8ea9985f522808d96c" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8004/v1/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "internal", "id": "7038e724c47d4acf9450868980fdd056" } ], "type": "orchestration", "id": "4a5dec5ab46f49d7beaed36e339a7653", "name": "heat" }, { "endpoints": [ { "region_id": "RegionOne", "url": "http://192.168.10.10:9292", "region": "RegionOne", "interface": "internal", "id": "2b85386b37e24940a54a1432b1f2e7a6" }, { "region_id": "RegionOne", "url": "http://10.20.30.40:9292", "region": "RegionOne", "interface": "public", "id": "30023a0f6be14da79d44179d14a87102" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:9292", "region": "RegionOne", "interface": "admin", "id": "735a2590fb4443119c7f484d2a346b22" } ], "type": "image", "id": "4cedd46ddf87492f813a018223c38889", "name": "glance" }, { "endpoints": [ { "region_id": "RegionOne", "url": "http://10.20.30.40:8041", "region": "RegionOne", "interface": "public", "id": "159c88f3663d44c996b07ef9f3a57d1c" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8041", "region": "RegionOne", "interface": "admin", "id": "32c5950c2e794bd988a991cc801ec4dd" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8041", "region": "RegionOne", "interface": "internal", "id": "e80c8a7152a0438a90b7e522d0ccc766" } ], "type": "metric", "id": "8f0f81ca23594fb3b73ccf4eb377f1ab", "name": "gnocchi" }, { "endpoints": [ { "region_id": "RegionOne", "url": "http://192.168.10.10:9696", "region": "RegionOne", "interface": "admin", "id": "06adbd070f9540ec9509173afbf2bf37" }, { "region_id": "RegionOne", "url": "http://10.20.30.40:9696", "region": "RegionOne", "interface": "public", "id": "1f1dff8c4a7a40e6a961b5a747b81be5" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:9696", "region": "RegionOne", "interface": "internal", "id": "7fbe273abc0f488dadb5e7eed073df84" } ], "type": "network", "id": "9498c977e8bb4f2db49753a9e2fbf2b3", "name": "neutron" }, { "endpoints": [ { "region_id": "RegionOne", "url": "http://192.168.10.10:8042", "region": "RegionOne", "interface": "admin", "id": "191853830fcd4ee5a0952aa7159f2013" }, { "region_id": "RegionOne", "url": "http://10.20.30.40:8042", "region": "RegionOne", "interface": "public", "id": "201ada5c54a3409f86a6274da15bf41c" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8042", "region": "RegionOne", "interface": "internal", "id": "b0d552b0acb84b468e8f88be8cf7aba3" } ], "type": "alarming", "id": "98aad662d1cc4eecaab0db2fdbab1051", "name": "aodh" }, { "endpoints": [ { "region_id": "RegionOne", "url": "http://192.168.10.10:5000", "region": "RegionOne", "interface": "internal", "id": "444cf011c99140b1ac4075166cff9674" }, { "region_id": "RegionOne", "url": "http://10.20.30.40:5000", "region": "RegionOne", "interface": "public", "id": "5916914330ea4a1cb21685185fc66e0d" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:35357", "region": "RegionOne", "interface": "admin", "id": "eab8104080794b0598e869216453fa8f" } ], "type": "identity", "id": "a4c590f0c3a34f88b307e3b8f56f8590", "name": "keystone" }, { "endpoints": [ { "region_id": "RegionOne", "url": "http://192.168.10.10:8000/v1", "region": "RegionOne", "interface": "internal", "id": "5b3bdd1d3f464dfd9a129e803a0e6abb" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8000/v1", "region": "RegionOne", "interface": "admin", "id": "d57b320562db4e11b8e8de970cfebeca" }, { "region_id": "RegionOne", "url": "http://10.20.30.40:8000/v1", "region": "RegionOne", "interface": "public", "id": "f133dc34fda84fa58c61d930fc503b24" } ], "type": "cloudformation", "id": "c52f8d928ad049829d479bf42ac001ca", "name": "heat-cfn" }, { "endpoints": [ { "region_id": "RegionOne", "url": "http://192.168.10.10:8774/v2.1/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "admin", "id": "0249b3d1bfad479891cc19a013305e26" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8774/v2.1/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "internal", "id": "a1f45c7d75c0491cbe37c10fe7316d80" }, { "region_id": "RegionOne", "url": "http://10.20.30.40:8774/v2.1/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "public", "id": "a52b2c2a9d5a4e0b848158d0de01ab96" } ], "type": "compute", "id": "c86a221cbf86436baeade82b6dc5c2c0", "name": "nova" }, { "endpoints": [ { "region_id": "RegionOne", "url": "http://10.20.30.40:8776/v2/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "public", "id": "434e9794843c439198dc9d511ea3448b" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8776/v2/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "admin", "id": "90a45092c587455b8f86d5075e6ee6e2" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8776/v2/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "internal", "id": "d18f263c67374797a5d3864711f28824" } ], "type": "volumev2", "id": "c8f33cf0b0fb400eb11eb52c0ea590cf", "name": "cinderv2" }, { "endpoints": [ { "region_id": "RegionOne", "url": "http://10.20.30.40:8776/v1/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "public", "id": "3b39e85a0871450b8aa3e102bcdb5ff4" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8776/v1/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "admin", "id": "81fc13b2aa994991a9dcab420c0d4c96" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8776/v1/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "internal", "id": "d0b202d1e65048f2bd067ae28e58be13" } ], "type": "volume", "id": "cfd3768ec7f244c1a9b0584dd6282e0d", "name": "cinder" }, { "endpoints": [ { "region_id": "RegionOne", "url": "http://10.20.30.40:8780", "region": "RegionOne", "interface": "public", "id": "a7dd90f864d844f296a7aafe75cd9b5d" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8780", "region": "RegionOne", "interface": "admin", "id": "c3cfdf635f1d422da9759754b2893366" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8780", "region": "RegionOne", "interface": "internal", "id": "facffa1c51e64e4e811423d817f01df4" } ], "type": "placement", "id": "dfcefb78800744aca1e99dfb9e99231c", "name": "placement" }, { "endpoints": [ { "region_id": "RegionOne", "url": "http://10.20.30.40:8774/v2/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "public", "id": "69181cb100194d269a39e161dbb3a98e" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8774/v2/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "internal", "id": "7f979b5fd0a84d8f953b213e8f9000de" }, { "region_id": "RegionOne", "url": "http://192.168.10.10:8774/v2/55b657d7e83243d2badff82cf1971b24", "region": "RegionOne", "interface": "admin", "id": "c14d6d743ab1414594f584c79c07514e" } ], "type": "compute_legacy", "id": "e07b5c806e6e4871a7d497d49aced37e", "name": "nova_legacy" } ], "user": { "password_expires_at": null, "domain": { "id": "default", "name": "Default" }, "id": "c13ce9221b404fb680794235237f40ff", "name": "hanlp123" }, "audit_ids": [ "dUar2k_cSVqEcbBDDCxzaQ" ], "issued_at": "2020-08-07T06:59:26.000000Z" } } ```