ASF API download authentication libcURL

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
loris.copa
Posts: 3
Joined: Wed Feb 21, 2024 5:43 am America/New_York
Answers: 0

ASF API download authentication libcURL

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

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

Tags:

ASF - bhauer
User Services
User Services
Posts: 25
Joined: Tue Dec 03, 2019 3:56 pm America/New_York
Answers: 0

Re: ASF API download authentication libcURL

by ASF - bhauer » Fri Feb 23, 2024 12:23 am America/New_York

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
Bill Hauer
Alaska Satellite Facility DAAC
User Support Office
uso@asf.alaska.edu

loris.copa
Posts: 3
Joined: Wed Feb 21, 2024 5:43 am America/New_York
Answers: 0

Re: ASF API download authentication libcURL

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

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?

ASF - bhauer
User Services
User Services
Posts: 25
Joined: Tue Dec 03, 2019 3:56 pm America/New_York
Answers: 0

Re: ASF API download authentication libcURL

by ASF - bhauer » Wed Feb 28, 2024 1:13 pm America/New_York

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
Bill Hauer
Alaska Satellite Facility DAAC
User Support Office
uso@asf.alaska.edu

loris.copa
Posts: 3
Joined: Wed Feb 21, 2024 5:43 am America/New_York
Answers: 0

Re: ASF API download authentication libcURL

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

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

ASF - bhauer
User Services
User Services
Posts: 25
Joined: Tue Dec 03, 2019 3:56 pm America/New_York
Answers: 0

Re: ASF API download authentication libcURL

by ASF - bhauer » Wed Mar 27, 2024 5:54 pm America/New_York

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
Bill Hauer
Alaska Satellite Facility DAAC
User Support Office
uso@asf.alaska.edu

Post Reply