Discussion:
curl -u problem escaping special chars in password
(too old to reply)
Leo Lagos
2018-10-03 19:03:49 UTC
Permalink
Hi,
I've being testing some REST API with curl, and today I was given a
different api-specific user to use. Problem is the password has some
special chars.

Now, this GET request works fine with my personal user. So method is OK.
Also, this "apiuser" works fine in Postman.

However, in curl I've been unable to figure out the correct escaping for -u:
$ curl -stderr -u "apiuser:jsd2018%##" -G http://*****
...
<p>Basic Authentication Failure - Reason :
AUTHENTICATION_DENIED</p>
...

However, in Postman, I can see the correct result using same user/password.

{
"size": 2,
"start": 0,
"limit": 50,
"isLastPage": true,
...
"values": [
...
]
}

So, could someone please help me figure out the obvious error I'm making?

Thanks in advance!

Regards,
Ray Satiro
2018-10-03 20:23:38 UTC
Permalink
Post by Leo Lagos
I've being testing some REST API with curl, and today I was given a
different api-specific user to use. Problem is the password has some
special chars.
Now, this GET request works fine with my personal user. So method is OK.
Also, this "apiuser" works fine in Postman.
$ curl -stderr -u "apiuser:jsd2018%##" -G  http://*****
...
AUTHENTICATION_DENIED</p>
...
However, in Postman, I can see the correct result using same
user/password.
{
    "size": 2,
    "start": 0,
    "limit": 50,
    "isLastPage": true,
...
   "values": [
...
    ]
}
So, could someone please help me figure out the obvious error I'm making?
Are you using the cURL that's generated by postman [1]? That -stderr is
suspect did you mean --stderr <file>? Is the percent symbol a special
character in your shell? Try using single quotes instead of double
quotes and see if it makes a difference. Other than that maybe there is
some header or different method of authentication sent by postman.

[1]:
http://blog.getpostman.com/2016/02/03/curl-and-postman-work-wonderfully-together/




-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se
Leo Lagos
2018-10-05 11:55:10 UTC
Permalink
Thanks Jim,

The problem is on the first platform I tried, which is Cygwin...I tried
this also on RHEL, just today, and it doesn't happen on Linux...

So, time to write to the cygwin mail..

Regards,
Post by Leo Lagos
$ curl -stderr -u "apiuser:jsd2018%##" -G http://*****
...
AUTHENTICATION_DENIED</p>
Assuming your running this on a Linux/Unix system under bash or similar
shell, try enclosing the user:password parameter in single quotes (')
rather than double quotes (")
Loading...