473,785 Members | 2,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cURL with Perl

46 New Member
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",real m="rets@marketl inx.com",nonce= "343baa915fcdf5 13c28822dd5e99f 683",opaque="06 0518134015940"
WWW-Authenticate: Digest qop="auth",real m="rets@marketl inx.com",nonce= "343baa915fcdf5 13c28822dd5e99f 683",opaque="06 0518134015940"
< 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 12079
numberwhun
3,509 Recognized Expert Moderator Specialist
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",real m="rets@marketl inx.com",nonce= "343baa915fcdf5 13c28822dd5e99f 683",opaque="06 0518134015940"
WWW-Authenticate: Digest qop="auth",real m="rets@marketl inx.com",nonce= "343baa915fcdf5 13c28822dd5e99f 683",opaque="06 0518134015940"
< 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 "Unauthoriz ed" is telling me you cannot.

Regards,

Jeff
May 6 '08 #2
rottmanj
46 New Member
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 Recognized Expert Contributor
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",real m="rets@marketl inx.com",nonce= "343baa915fcdf5 13c28822dd5e99f 683",opaque="06 0518134015940"
WWW-Authenticate: Digest qop="auth",real m="rets@marketl inx.com",nonce= "343baa915fcdf5 13c28822dd5e99f 683",opaque="06 0518134015940"
< 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
rottmanj
46 New Member
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:$pas s"

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
3338
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 linux that's only like 3 months old (fedora c2 stable), because curl needs libcrypto.so.4. 3. In order to install libcrypto.so.4 I have to upgrade my openssl (took me forever to figure that out).
3
6332
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(): http://www.canadiandropshipping.com/hello.php3 Does anyone know why this ssl curl test fails? http://www.canadiandropshipping.com...t/diag_curl.php
9
12598
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 programming of web pages and not just running "scripts" which have in-roads into service DLLs of other languages such as C#. Surely MS will put Curl into .NET at some time since it is designed to work with DirectX and OpenGL?
4
10629
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, exploiting a vulnerability in php code. The requests are like this 216.120.231.252 - - "GET /algebra/about/history/config.php?returnpath=http://domates.1gig.biz/spread.txt? HTTP/1.1" 404 561 "-" "libwww-perl/5.805"
4
3710
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 functionality of php. The extension uses the '$perl->eval' function. i am kind of stuck with the syntax or how to put the php variable into the perl script. I have a form where the user puts in a grid reference. Then a php script that gets the...
7
55146
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 monopoly on the issue of Perl on the Windows platform As anyone who code's Perl on the Windows platform knows, the choice that you have (had) for Perl on Windows was Active State. It worked great for your scripting but when it came to installing...
3
10105
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 perl curl. At this point I can get the system curl to correctly connect to my server. However, I am having the hardest time trying to figure out why I cant get perl curl to connect to the server. Every time I try to connect, I get a 401 error. I am...
1
1804
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 decribed in the books "Spidering Hacks" and "Perl & LWP". I am familiar with the book "Webbots, Spiders, and Screen Scrapers: A Guide to Developing Internet Agents with PHP/CURL" Would anyone know of any other sources of info related to this kind...
3
1657
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(); curl_setopt_array($ch, array(
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7496
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.