Terrascope logo Proba-V MEP logo
This forum applies to Terrascope and Proba-V MEP. Please note that the forum is in English only.
Please log in using the link in the top menu to add new forum topics or comments.

Download files using opensearch returned link: error 401

Dear Support,                    our system supports the possibility to get images from the shared drive or via OpenSearch from different nodes. In the past we were able to search and donwload files. Now we receive http 401 when we try to download. The system makes and opensearch query, it works, then takes the link from the Atom result and make a request to download the file. Our code (in Java) used the http authentication that worked before.  The code snippet is: ________________________________________ // Basic HTTP Authentication m_oLogger.debug("ProviderAdapter.downloadViaHttp: sDownloadUser = " + sDownloadUser); Authenticator.setDefault(new Authenticator() {      protected PasswordAuthentication getPasswordAuthentication() {           try {                return new PasswordAuthentication(sDownloadUser, sDownloadPassword.toCharArray());           } catch (Exception oEx) {                   m_oLogger.error("ProviderAdapter.downloadViaHttp: exception setting auth " + org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(oEx));           }           return null;     } }); m_oLogger.debug("ProviderAdapter.downloadViaHttp: FileUrl = " + sFileURL); URL oUrl = new URL(sFileURL); HttpURLConnection oHttpConn = (HttpURLConnection) oUrl.openConnection(); oHttpConn.setRequestMethod("GET"); oHttpConn.setRequestProperty("Accept", "*/*"); oHttpConn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0"); int responseCode = oHttpConn.getResponseCode(); // always check HTTP response code first if (responseCode == HttpURLConnection.HTTP_OK) {                   m_oLogger.debug("ProviderAdapter.downloadViaHttp: Connected"); ________________________________________   I'm sure that user and password are correct (tried with user interface).   Can you help us to solve this issue? Is Basic Authentication already supported? Is there any other way to authenticate "by code" ? Or any other way to download the products by code and not by hand? Thank you very much Paolo 


Dear Dirk, we made some test and you are right. We changed the code to generate the http header "by hand" and it is working now. In this moment, I'm not able to read the downloaded file with SNAP, but I'll check more before bothering you :) Thank you very much Paolo  

Hi Paolo, basic authentication is still supported. We tried to download the link using two different accounts via basic authentication and it seems to work fine. Some clients (e.g wget) first send an GET request without an Authorization header, so then it is normal that the server first replies with a 401 error code, then the client will do another request including the basic authentication header. I am not sure how your Java client handles this. So, if you did not already, can you try to download the same file via wget or curl? Does the server also provide more info in the body of the response? Thanks, Dirk

Here you have a sample link: https://www.vito-eodata.be/PDF/dataaccess?service=DSEO&request=GetProduct&version=1.0.0&collectionID=1000060&productID=282844947&ProductURI=urn:ogc:def:EOP:VITO:PROBAV_L2A_1KM_V001:PROBAV_RIGHT_L2A_20191029_082028_1KM:V101& Thanks

Hi Paolo, can you give us an example URL for which the download fails? Thanks, Dirk

Hi Paolo, sorry for the delay - many colleagues are on holiday. We will come back to you early next week. Jurgen
blijf op de hoogte!
abonneer op onze nieuwsbrief
nieuwe perspectieven

Blijf op de hoogte!