gpt4 book ai didi

token - 如何获取 openstack token 并对其进行验证?

转载 作者:行者123 更新时间:2023-12-04 13:53:05 28 4
gpt4 key购买 nike

我遵循了本指南:http://keystone.openstack.org/api_curl_examples.html

似乎我通过运行获得了一个有效的 token :

curl -d '{"auth":{"passwordCredentials":{"username": "can", "password": "mypassword"}}}' -H "Content-type: application/json" http://url:35357/v2.0/tokens

它返回:
{
"access":
{
"token":
{
"expires": "2012-05-21T14:35:17Z",
"id": "468da447bd1c4821bbc5def0498fd441"
},
"serviceCatalog": {},
"user":
{
"username": "can",
"roles_links": [],
"id": "bb6d3a09ad0c4924bf20c1a32ccb5781",
"roles": [],
"name": "can"
}
}
}

但是当我进入接下来的几个部分来验证这个 token 时,我遇到了这个神奇的数字: X-Auth-Token:999888777666 . 起初我以为这是我得到的 token ,但我错了。

我想我可能漏掉了一些东西,所以我阅读了 openstack 文档( http://keystone.openstack.org/configuration.htmlhttp://docs.openstack.org/api/openstack-compute/programmer/content/ )中的相关部分,但仍然不知道这个数字是怎么来的。

谁能给我解释一下
  • 这个神奇的数字是什么意思
  • 如何获得它的正确值,以便我可以获得一个工作 token 来管理 openstack 的其他部分
  • 最佳答案

    这个神奇的数字(实际上是字符串)是 keystone.conf 文件中的 admin_token 设置。在 keystone.conf 设置的 [DEFAULT] 部分下

    admin_token = abcd1234

    如果您不将其用于管理操作,您将看到类似
    ubuntu@i-000004bc:~/devstack$ curl http://localhost:35357/v2.0/tenants
    {"error": {"message": "The request you have made requires authentication.", "code": 401, "title": "Not Authorized"}}

    如果你确实使用它,你会看到类似的东西
    ubuntu@i-000004bc:~/devstack$ curl -H "X-Auth-Token: abcd1234" http://localhost:35357/v2.0/tenants
    {"tenants_links": [], "tenants": [{"enabled": true, "description": null, "name": "demo", "id": "aee8a46babcb4e4286021c8f6ef996cd"}, {"enabled": true, "description": null, "name": "invisible_to_admin", "id": "de17fea45de148ada0a58e998e6c3e73"}, {"enabled": true, "description": null, "name": "admin", "id": "f34b0c8ab30e450489b121fbe723fde5"}, {"enabled": true, "description": null, "name": "service", "id": "fbe3e2e530fd47298cb2cba1b4afa3da"}]}

    关于token - 如何获取 openstack token 并对其进行验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10674588/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com