I'm trying to download a zip file from a provider, using wget works fine:
wget -c --http-user=MY_UN --http-password=MY_PW "https://datapool.asf.alaska.edu/GRD_MD/SA/S1A_EW_GRDM_1SDH_20151003T040339_20151003T040351_007983_00B2A6_7377.zip"
However using the Python Requests library I get 401 errors using the same credentials, does anybody know why that might be, or where to look to begin understanding the problem?
url = "https://datapool.asf.alaska.edu/GRD_MD/SA/S1A_EW_GRDM_1SDH_20151003T040339_20151003T040351_007983_00B2A6_7377.zip"
r = requests.get(url, auth=("MY_UN", "MY_PW"), stream = True)
I should mention that I have quadruple checked the details, and they are correct on both. Is there an alternative method in Python?
In the mean time I have had to spawn a wget using the os package:
os.system("wget -c --http-user=MY_UN--http-password=MY_PW 'https://datapool.asf.alaska.edu/GRD_MD/SA/S1A_EW_GRDM_1SDH_20151003T040339_20151003T040351_007983_00B2A6_7377.zip'")
rprefix to your string.wgetsupports multiple types of authentication when passinghttp-user/--http-password. It is likely your app is using a different type like Digest or NTLM. That would explain why your example in wget works while requests failed. The docs for requests have examples for different authentication here: 2.python-requests.org/en/master/user/authentication