Receiving 401 - Unauthorized: Access is denied due to invalid credentials
I am able to successfully get a RETS response when going to http://manhattan.rets.paragonrels.com... in a web browser, my user is SRram1, but when I try to use cURL to login, I get the access is denied due to invalid credentials error.
In other RETS implementations we are able to use cURL to login, send a search query, and get results back for our integration.
Comments
Are you using Digest authentication with cURL for your login?
I am not currently. I tried connecting with and without it and still receive the error.
With http we use digest. With https we use Basic.
Ok I tried adding digest since I'm connecting to http. I'm still receiving the error.
I'm working with a simplified cURL right now just trying to get a successful connect. I'll post my code in a few comments due to character limits.
$curlRets = curl_init(); $headers[] = "Accept: /"; $headers[] = "RETS-Version: RETS/1.7.2"; $headers[] = "User-Agent: RETSConnector/1.0"; curl_setopt($curlRets, CURLOPT_URL, $loginURL); curl_setopt($curlRets, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curlRets, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlRets, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); curl_setopt($curlRets, CURLOPT_USERPWD, $username.":".$password);
$output = curl_exec($curlRets); curl_close($curlRets);
Looks like the line breaks were taken out. Hopefully that helps. Is there a sample cURL code that you have that I could try?
Any assistance with cURL sample code would be greatly appreciated.
You may be better off using PHRETS than trying to roll your own. It will make it much easier to work with RETS. https://github.com/troydavisson/PHRETS
Were you able to get this working using PHRETS?
I have downloaded it and have been trying to get it to work. I am unfamiliar with Composer, though, which it says to use to "install" PHRETS. I found instructions on installing locally with Composer then just copy up the files to the server, which I'll be working on next.
Glad to hear you are making some progress. I'm not a PHP developer, but I was able to follow the instructions and use composer to install the needed components. Just running scripts from the command line I was able to login, search and download data and logout.
I was able to install composer and get PHRETS unpacked. I've copied up to the server and tried running, but I'm getting syntax errors due to the splat operators. Trying to troubleshoot that issue now.
Ok, the issue is the server is running php version 5.4.16 and PHRETS requires 5.6 minimum. I'll likely need another solution.
Sorry to hear that. It's much better to use an existing tool than to try to roll your own from scratch.
Any insight or ideas why that cURL would be returning an invalid credentials error?
No. But you could maybe look at the PHRETS source on GitHub and get some idea of how the connection is being made using cURL.