Openstack token,我可以用 curl 获取令牌,但不能用 urllib



sandy@Swift_PC:~$curl-D-H'X-Storage-User:Lucy'

sandy@Swift_PC:~$ curl -D- -H 'X-Storage-User:Lucy' http://192.168.119.89:8080/auth/v1.0
HTTP/1.1 200 OK
X-Storage-Url: http://192.168.119.89:8080/v1/AUTH_Lucy
X-Auth-Token: AUTH_tk713d067336d24348bcea1ab220965785
Content-Type: text/html; charset=UTF-8
X-Storage-Token: AUTH_tk713d067336d24348bcea1ab220965785
X-Trans-Id: tx8a03bc278f6d4ab899a25-00557554df
Content-Length: 0
Date: Mon, 08 Jun 2015 08:39:59 GMT

我可以把X-Storage-token卷起来。

import urllib,httplib,json
from urlparse import urlparse
user = "Lucy"
url = "192.168.119.89:8080"
ports = "/auth/v1.0"
params = urllib.urlencode({})
headers = {"X-Storage-User":user,"Content-type":"application/json"}
conn = httplib.HTTPConnection(url)
conn.request("GET","%s" %ports,params,headers)
response = conn.getresponse()
data = response.read()
print response

我想用curl获得代币。它什么也不回。如果我不想以其他方式获得curl的代币,我该怎么办?

感谢

X-Storage-Token在标头中,而不是在正文中。

尝试token = response.getheader('X-Storage-Token')

相关内容

  • 没有找到相关文章

最新更新