473,238 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,238 software developers and data experts.

cURL with Perl

I am working on a revamp of a previous application that I have written in coldfusion. The application deals with RETS data. The issue that I am having is with using the curl option HTTP_AUTH and CURLAUTH_DIGEST.

When attempting to authenticate against the server. No matter what I try, my authentication always fails. I have made sure to validate the auth information.

In my testings, I have also verified that curl can authenticate via the command line option.

Here is my current testing code base.

Expand|Select|Wrap|Line Numbers
  1.  
  2. my $curl= new WWW::Curl::easy;
  3. $curl->setopt(CURLOPT_VERBOSE,1); 
  4. $curl->setopt(CURLOPT_HTTPAUTH,CURLAUTH_ANY);  
  5. $curl->setopt(CURLOPT_USERPWD, '$user:$pass'); 
  6. $curl->setopt(CURLOPT_URL, $site);
  7. my $retcode = $curl->perform;
  8.  
  9. print $retcode;
  10.  

This is the error I receive back.

< HTTP/1.1 401 Unauthorized
HTTP/1.1 401 Unauthorized
< Content-Length: 1944
Content-Length: 1944
< Content-Type: text/html
Content-Type: text/html
< Server: Microsoft-IIS/6.0
Server: Microsoft-IIS/6.0
< X-Powered-By: ASP.NET
X-Powered-By: ASP.NET
< WWW-Authenticate: Digest qop="auth",realm="rets@marketlinx.com",nonce="343b aa915fcdf513c28822dd5e99f683",opaque="060518134015 940"
WWW-Authenticate: Digest qop="auth",realm="rets@marketlinx.com",nonce="343b aa915fcdf513c28822dd5e99f683",opaque="060518134015 940"
< Date: Tue, 06 May 2008 18:13:40 GMT
Date: Tue, 06 May 2008 18:13:40 GMT
< Connection: close
Connection: close
May 6 '08 #1
4 11983
numberwhun
3,509 Expert Mod 2GB
I am working on a revamp of a previous application that I have written in coldfusion. The application deals with RETS data. The issue that I am having is with using the curl option HTTP_AUTH and CURLAUTH_DIGEST.

When attempting to authenticate against the server. No matter what I try, my authentication always fails. I have made sure to validate the auth information.

In my testings, I have also verified that curl can authenticate via the command line option.

Here is my current testing code base.

Expand|Select|Wrap|Line Numbers
  1.  
  2. my $curl= new WWW::Curl::easy;
  3. $curl->setopt(CURLOPT_VERBOSE,1); 
  4. $curl->setopt(CURLOPT_HTTPAUTH,CURLAUTH_ANY);  
  5. $curl->setopt(CURLOPT_USERPWD, '$user:$pass'); 
  6. $curl->setopt(CURLOPT_URL, $site);
  7. my $retcode = $curl->perform;
  8.  
  9. print $retcode;
  10.  

This is the error I receive back.

< HTTP/1.1 401 Unauthorized
HTTP/1.1 401 Unauthorized
< Content-Length: 1944
Content-Length: 1944
< Content-Type: text/html
Content-Type: text/html
< Server: Microsoft-IIS/6.0
Server: Microsoft-IIS/6.0
< X-Powered-By: ASP.NET
X-Powered-By: ASP.NET
< WWW-Authenticate: Digest qop="auth",realm="rets@marketlinx.com",nonce="343b aa915fcdf513c28822dd5e99f683",opaque="060518134015 940"
WWW-Authenticate: Digest qop="auth",realm="rets@marketlinx.com",nonce="343b aa915fcdf513c28822dd5e99f683",opaque="060518134015 940"
< Date: Tue, 06 May 2008 18:13:40 GMT
Date: Tue, 06 May 2008 18:13:40 GMT
< Connection: close
Connection: close
I would check, without using your script, that you can log into the website first. The error "Unauthorized" is telling me you cannot.

Regards,

Jeff
May 6 '08 #2
I have already verified that I am able to log in. The Unauthorized is part of the ResponseHeaders that I receive back.
May 6 '08 #3
nithinpes
410 Expert 256MB
I am working on a revamp of a previous application that I have written in coldfusion. The application deals with RETS data. The issue that I am having is with using the curl option HTTP_AUTH and CURLAUTH_DIGEST.

When attempting to authenticate against the server. No matter what I try, my authentication always fails. I have made sure to validate the auth information.

In my testings, I have also verified that curl can authenticate via the command line option.

Here is my current testing code base.

Expand|Select|Wrap|Line Numbers
  1.  
  2. my $curl= new WWW::Curl::easy;
  3. $curl->setopt(CURLOPT_VERBOSE,1); 
  4. $curl->setopt(CURLOPT_HTTPAUTH,CURLAUTH_ANY);  
  5. $curl->setopt(CURLOPT_USERPWD, '$user:$pass'); 
  6. $curl->setopt(CURLOPT_URL, $site);
  7. my $retcode = $curl->perform;
  8.  
  9. print $retcode;
  10.  

This is the error I receive back.

< HTTP/1.1 401 Unauthorized
HTTP/1.1 401 Unauthorized
< Content-Length: 1944
Content-Length: 1944
< Content-Type: text/html
Content-Type: text/html
< Server: Microsoft-IIS/6.0
Server: Microsoft-IIS/6.0
< X-Powered-By: ASP.NET
X-Powered-By: ASP.NET
< WWW-Authenticate: Digest qop="auth",realm="rets@marketlinx.com",nonce="343b aa915fcdf513c28822dd5e99f683",opaque="060518134015 940"
WWW-Authenticate: Digest qop="auth",realm="rets@marketlinx.com",nonce="343b aa915fcdf513c28822dd5e99f683",opaque="060518134015 940"
< Date: Tue, 06 May 2008 18:13:40 GMT
Date: Tue, 06 May 2008 18:13:40 GMT
< Connection: close
Connection: close
Using single quotes around variables will block the substitution of those variables(will be considered literal string). Change:
Expand|Select|Wrap|Line Numbers
  1. $curl->setopt(CURLOPT_USERPWD, '$user:$pass'); 
  2.  
to

Expand|Select|Wrap|Line Numbers
  1. $curl->setopt(CURLOPT_USERPWD, "$user:$pass"); 
  2.  
That's how this line should be, though this may/may not solve your issue.
May 7 '08 #4
I am having a heck of a time getting this to work. Every example that I have found uses pretty much what I have here.

At first glance it looks like it is trying to use Basic auth, but I know for a fact that this server uses digest auth.

As I have said before.

Verified that server uses Digest auth
Verified username and password
Verified that URI
Tried with '$user:$pass' and "$user:$pass"

Any help with this would be greatly appreciated.

Here is the output that I get from my app.

Expand|Select|Wrap|Line Numbers
  1. About to connect() to rets.armls.mlsrets.com port 80 (#0)
  2.   Trying 65.83.83.235... connected
  3. Connected to rets.armls.mlsrets.com (65.83.83.235) port 80 (#0)
  4. Server auth using Basic with user '*********'
  5. GET /rets/login HTTP/1.1
  6. Authorization: Basic Q1JJTDAxOkpuITIzQA==
  7. Host: rets.armls.mlsrets.com
  8. Accept: */*
  9.  
  10.  
  11. HTTP/1.1 401 Unauthorized
  12. HTTP/1.1 401 Unauthorized
  13. Content-Length: 1944
  14. Content-Length: 1944
  15. Content-Type: text/html
  16. Content-Type: text/html
  17. Server: Microsoft-IIS/6.0
  18. Server: Microsoft-IIS/6.0
  19. X-Powered-By: ASP.NET
  20. X-Powered-By: ASP.NET
  21. WWW-Authenticate: Digest qop="auth",realm="rets@marketlinx.com",nonce="44722adb40435c5b13ac90bd5704d271",opaque="14052119422857"
  22. WWW-Authenticate: Digest qop="auth",realm="rets@marketlinx.com",nonce="44722adb40435c5b13ac90bd5704d271",opaque="14052119422857"
  23. Date: Wed, 14 May 2008 21:19:41 GMT
  24. Date: Wed, 14 May 2008 21:19:41 GMT
  25. Connection: close
  26. Connection: close
May 14 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: mrbog | last post by:
1. In order to make an http (or https) request with PHP, I need to recompile php with cURL. 2. In order to install CURL I have to upgrade my openssl rpm, even though I'm runing a version of...
3
by: Chris Fortune | last post by:
# uname -a Linux stargate.mxc-online.net 2.4.20-021stab022.2.777-smp #1 SMP Wed Jul 28 17:12:37 MSD 2004 i686 i686 i386 GNU/Linux I recompiled PHP with mcrypt, openssl, and curl phpinfo():...
9
by: Conrad F | last post by:
Hi, If any Microsoft people are listening.... Are there any plans for the new web language called "Curl" to be supported in .NET (ASP.NET)? I ask as Curl represents the first step to true OO...
4
by: Ignoramus6539 | last post by:
There were some strange requests to my server asking for config.php file (which I do not have in the requested location). I did some investigation. Seems to be a virus written in perl,...
4
by: billb | last post by:
I installed a perl extension for PHP to use some perl inside my php primarily because I have perl working with oracle and not php and oracle. So I want to use my old perl scripts, and use the...
7
numberwhun
by: numberwhun | last post by:
**NOTE: This article is written using the 5.8.8 Alpha2 release of Strawberry Perl. I am writing this article with much joy and glee. This is due to the fact that Active State no longer has a...
3
by: rottmanj | last post by:
I am re-writing my rets application in perl, and I have found a few modules that will help me on my way. One of them being WWW::Curl:easy. During my testing, I have tested both system curl and...
1
by: George Orwell | last post by:
Would I be missing much if I stopped trying to learn Perl well enough to use for spidering, screen scraping etc. and converted over to PHP ? I am looking to do all, or at least most of the hacks...
3
by: webb315 | last post by:
I m new to perl only know basics. but can any one help me with this CURL? I have this php curl.. want to change it to perl.. PHP Code: function curl($a,$b,$c,$d,$e){ $ch = curl_init(); ...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.