Openstack身份验证始终获得401 HTTP响应

时间:2016-07-26 03:20:46

标签: amazon-web-services authentication curl cloud openstack

我最近在openstack上做项目。我开始吧我想通过RESTful API访问openstack帐户。我在官方网站上阅读了API指南。链接在这里http://developer.openstack.org/api-guide/quick-start/api-quick-start.html#authenticate

我以同样的方式进行身份验证。

这是我的命令:

curl -s -X POST https://url:5000/v2.0/tokens -H "Content-Type: application/json" -d '{"auth": {"tenantName": "MyTenantName", "passwordCredentials": {"username": "'"myAccountNme"'", "password": "mypassword"}}}'

但每次我得到401 (Unauthorized)回复说The request you have made requires authentication。错误消息为here.

我的要求有什么问题?我的用户名和密码是正确的,我可以用它来从仪表板访问我的帐户。

1 个答案:

答案 0 :(得分:0)

由于您使用的是https,我认为您收到错误消息,因为您没有指定证书。使用curl的--cert或--cacert选项。像这样:

curl --cacert <your_crt_file> -X POST https://url:5000/v2.0/tokens -H "Content-Type: application/json" -d '{"auth": {"tenantName": "MyTenantName", "passwordCredentials": {"username": "'"myAccountNme"'", "password": "mypassword"}}}'
相关问题