How to download a file from assembla with a key and a secret using a python script

108 views Asked by At
import requests

url = 'https://api.assembla.com/v1/spaces'
API_KEY = "API_KEY"
API_SECRET = "API_SECRET "
resp = requests.get(url, auth=(API_KEY, API_SECRET))
print(resp.status_code)

I keep getting 401. I'm not sure how to use an API_KEY and an API_SECRET to download a pdf file (let's call it test.pdf) from an assembla url given to me. Any help appreciated.

1

There are 1 answers

2
fixatd On

Does seem like you need to use those as headers instead based from their documentation

import requests

url = 'https://api.assembla.com/v1/spaces'

headers = {
    "X-Api-Key": "API_KEY",
    "X-Api-Secret": "API_SECRET"
}

resp = requests.get(url, headers=headers)

See Customer Headers from the requests documentation