0

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

This works and returns exactly what I would expect it to.

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)

This does not and returns a 401 error. (PYTHON)

Icallitvera
  • 166
  • 1
  • 3
  • 13

1 Answers1

2

It should be:

request.add_header("Authorization", "BoxAuth api_key="+apikey+"&auth_token="+auth_token)
iMom0
  • 12,493
  • 3
  • 49
  • 61
  • thanks for the help, that didn't fix it but I did `headers = {'Authorization' : 'BoxAuth api_key='+apikey+'&auth_token='+auth_token,} request = urllib2.Request("https://api.box.com/2.0/folders/0", None, headers)` and that worked for me – Icallitvera Oct 17 '12 at 03:42
  • Python will add colon between them. :) – iMom0 Oct 17 '12 at 03:44