Page 1 of 1

ASF API download authentication libcURL

Posted: Wed Feb 21, 2024 5:59 am America/New_York
by loris.copa
Hello,

we are experiencing some issues trying to download data through cURL (from C++).

The issue arises when a password including special characters is used, returning a 401 response. Applying the fix reported here: https://docs.asf.alaska.edu/api/troubleshooting/ -> "Passwords with special characters will need to be inside quotes" seems to have no effect, returning a 401 response as well.

How should a password like password!1 be formatted in order to work with the ASF API? We have tried the following but none worked:

"password!1"
%22password!1%22
password%211
%22password%211%22

kind regards,
Loris

Re: ASF API download authentication libcURL

Posted: Fri Feb 23, 2024 12:23 am America/New_York
by ASF - bhauer
Hello Loris,
Try enclosing the password in single quotes ('password') and let us know if this doesn't help. And it doesn't hurt to enclose the username in quotes as well.

Thank you,
Bill Hauer

Re: ASF API download authentication libcURL

Posted: Fri Feb 23, 2024 2:09 am America/New_York
by loris.copa
Hello Bill,

thank you for your suggestion. Unfortunately the result is the same: 401 unauthorized.

The password I checked works both in the browser and with wget on linux (between single quotes), but not with libcURL. I tried three different options: plain text 'password!1', partially url encoded 'password%211' and fully url encoded %27password%211%27, but none worked. With older passwords not requiring special characters everything works fine even without quotes.

Do you have any other suggestion or a working curl command line example to try?

Re: ASF API download authentication libcURL

Posted: Wed Feb 28, 2024 1:13 pm America/New_York
by ASF - bhauer
Hello Loris,
The API team provides a troubleshooting section in their user guide that I hope can provide you an answer:

https://docs.asf.alaska.edu/api/troubleshooting/

Thanks,
Bill

Re: ASF API download authentication libcURL

Posted: Thu Feb 29, 2024 3:01 am America/New_York
by loris.copa
Dear Bill,

thank you for your reply. As you can see from the first post, I turned to this forum after consulting the troubleshooting page (the link you shared is the same as the one in the first post). The proposed 'solution' does not work, and the tools page does not provide an example of downloading a file with curl but only with wget.

In the meantime, we have found that authentication with special characters works exactly the opposite way: without quotation marks of any kind, but only partially. Characters like: !, $, &, +, work without quotes or php encoding, while other characters such as @ and # always return error codes (no quotes -> 413, double quotes -> 401, single quotes -> 401) for no apparent reason.

Is it possible to contact the ASF API team directly so that these problems can be resolved?

Kind regards,
Loris

Re: ASF API download authentication libcURL

Posted: Wed Mar 27, 2024 5:54 pm America/New_York
by ASF - bhauer
Loris,
Following up with the API team, they suggest the following:
  • Only URL encode the `!` part of the password.
If these don't help, you have the email address for the API team and they can work with you directly to find a solution.

Thanks,
Bill