curl-users
Basic Authentication from command-line cURL
Date: Tue, 19 Jul 2005 13:16:18 -0700 (PDT)
Hi all,
Just joined curl mailing list today ^_~.
I did my 'homework' first before posting this new
thread. I found out in the May-2005 archives with
subject: 'Post File to HTTPS via cURL at command
line'. But I couldn't find the answer related to my
problem.
I am using cURL 7.14.0 on Windows environment.
So, this is the problem that I encounter [I didn't
write -d option for this case, to make it shorter]
1. I try to send an XML message to 3rd party server,
over https connection, using basic authentication
2. Before sending the message, here are the
requirements from the 3rd party:
+ Concatenate the username and password, separating
them with a colon: "username:password"
+ Convert that concatenation into a UTF8 encoded
byte array
+ Convert that array into a BASE64 encoded string
+ Specify the authentication type of 'Basic':
"Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="
+ Set the resulting string to the Authorization
header
3. And this what I have done:
From command prompt I typed:
+ 1st attempt: using plain username and password:
C:\>curl -v --basic -u
"plain_username:plain_password"
https://staging.abc.com/AuthenticatingxmlServer.aspx
+ 2nd attempt: after calling
utf8_encode(plain_username:plain_password) function
from PHP and stored it into a variable
($thisvariable), call
base64_encode($thisvariable),and:
C:\>curl -v --basic -u
"c0VNMnVzZXIRTkUzNnQxRDg2cDMyNA=="
https://staging.abc.com/AuthenticatingxmlServer.aspx
+ 3rd attempt: $variable =
base64_encode($username).':'.base64_encode($password);
After getting this variable
C:\>curl -v --basic -u "$variable"
https://staging.abc.com/AuthenticatingxmlServer.aspx
4. The results that I got from 3 attempts:
+ 1st and 2nd: '401 Unauthorized'
+ 3rd: asking me a password, since option -u
required 'username:password' pair.
My question are:
1. How can I implement the No.2 requirements in cURL?
2. If I use 1st attempt (plain username:password),
does cURL automatically convert username:password with
base 64?
If somebody can give me pointers, suggestion or
anything related to this problem, I'll appreciate it.
Thanks for your help.
Laurent
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Received on 2005-07-19