Box-API在python中提供401但不包含cURL

时间:2012-10-17 03:34:10

标签: python curl box-api

curl https://api.box.com/2.0/folders/0 -H "Authorization: BoxAuth api_key=API_KEY&auth_token=AUTH_TOKEN"

这样可以正常返回我想要的内容。

request = urllib2.Request("https://api.box.com/2.0/folders/0")
request.addheaders = [("Authorization: BoxAuth", "api_key="+apikey+"&auth_token="+auth_token)]
response = urllib2.urlopen(request)

这不会,并返回401错误。 (PYTHON)

1 个答案:

答案 0 :(得分:2)

应该是:

request.add_header("Authorization", "BoxAuth api_key="+apikey+"&auth_token="+auth_token)