I am writing a script that downloads Sentinel 2 products (satellite imagery) using sentinelsat
Python API.
A product's description is structured as JSON and contains the parameter quicklook_url
.
Example:
Any Sentinel API calls require credentials. So does retrieving a product and also opening the link stored inside quicklook_url
. When I call the example in my browser I get asked to enter username and password in order to get
with the name S2A_MSIL2A_20210625T065621_N0300_R063_T39NTJ_20210625T093748-ql.jpg
.
Needless to say I am just starting with the API so I am probably missing something but
requests.post(product_description['quicklook_url'], verify=False, auth=HTTPBasicAuth(username, password)).content
yields 0KB damaged file and
requests.get(product_description['quicklook_url']).content
yields 1KB damaged file.
I have looked into requests.Session
session = requests.Session()
session.auth = (username, password)
auth = session.post('URL_FOR_LOGING_IN')
img = session.get(product_description['quicklook_url']).content
The problem is I am unable to find the URL I need to post my session authentification. I am somewhat sure that the sentinelsat
API does that but my looks have not yielded any successful result.
I am currently looking into the SentinelAPI
class. It has the download_quicklook()
function, which I am using right now but I am still curious how to do this without the function.