ASF API download authentication libcURL
-
- Posts: 3
- Joined: Wed Feb 21, 2024 5:43 am America/New_York
ASF API download authentication libcURL
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
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
Filters:
-
- Posts: 51
- Joined: Tue Dec 03, 2019 3:56 pm America/New_York
Re: ASF API download authentication libcURL
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
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
-
- Posts: 3
- Joined: Wed Feb 21, 2024 5:43 am America/New_York
Re: ASF API download authentication libcURL
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?
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?
-
- Posts: 51
- Joined: Tue Dec 03, 2019 3:56 pm America/New_York
Re: ASF API download authentication libcURL
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
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
-
- Posts: 3
- Joined: Wed Feb 21, 2024 5:43 am America/New_York
Re: ASF API download authentication libcURL
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
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
-
- Posts: 51
- Joined: Tue Dec 03, 2019 3:56 pm America/New_York
Re: ASF API download authentication libcURL
Loris,
Following up with the API team, they suggest the following:
Thanks,
Bill
Following up with the API team, they suggest the following:
- Enclose the entire URL in single quotes; e.g., curl 'https://datapool.blahblah.edu/somefile?password=abc%21123'
- Only URL encode the `!` part of the password.
Thanks,
Bill