Hi,
I am failing to connect to a rets server that is using digest authentication. First off i will say that this is working fine on
retsmd.com and using the RETS Connector client application, however when i use phrets its giving me the following error:
Fatal error: Uncaught exception
'GuzzleHttp\Exception\ClientException' with message 'Client error
response [url] http://matrixrets.alamls.net/rets/login.ashx [status
code] 401 [reason phrase] Access Denied' in
C:\wamp\www\rets\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:89
Stack
trace:
#0
C:\wamp\www\rets\vendor\guzzlehttp\guzzle\src\Subscriber\HttpError.php(33):
GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Message\Request),
Object(GuzzleHttp\Message\Response))
#1 C:\wamp\www\rets\vendor\guzzlehttp\guzzle\src\Event\Emitter.php(109):
GuzzleHttp\Subscriber\HttpError->onComplete(Object(GuzzleHttp\Event\CompleteEvent),
'complete')
#2 C:\wamp\www\rets\vendor\guzzlehttp\guzzle\src\RequestFsm.php(91):
GuzzleHttp\Event\Emitter->emit('complete',
Object(GuzzleHttp\Event\CompleteEvent))
#3 C:\wamp\www\rets\vendor\guzzlehttp\guzzle\src\RequestFsm.php(132):
GuzzleHttp\RequestFsm->__invoke(Object(GuzzleHttp\Transaction))
#4 C:\wamp\www\rets\vendor\react\promise\src\FulfilledPromise.php(25):
GuzzleHttp in C:\wamp\www\rets\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 89
Now i know that you guys have suggested in other threads with this error to try setting the cookies, however i have already done so. The thing i will say about this is that i am running a windows OS with a wamp server that i test my code on before pushing to my production server which is on linux. The reason why i bring this up is that my windows OS handles the temporary files that are created with tempnam and puts it in the C:\Windows\Temp directory with its own assigned name ("phr" follwed by 4 random characters ".tmp"). Anyways you can take a look at my code below.
$username = '51191RETS';
$password = '*****';
require_once('vendor/autoload.php');
//RETS URL
$rets_url = 'http://matrixrets.alamls.net/rets/';
//Login Page URL
$login_page = $rets_url . 'login.ashx';
$config = new \PHRETS\Configuration;
$config->setLoginUrl($login_page);
$config->setUsername($username);
$config->setPassword($password);
$config->setHttpAuthenticationMethod('digest');
$rets = new \PHRETS\Session($config);
$rets->getClient()->setDefaultOption('config', [
'curl' => [
CURLOPT_COOKIEFILE => tempnam('/tmp', 'phrets')
]
]);
$connect = $rets->Login();
$system = $rets->GetSystemMetadata();
vardump($system);
So on that note, any ideas or suggestions on what I am doing wrong or how i could fix this?
Also as a complete sidenote, I went digging for answers to this issue on my own (like i typically would be doing), when i go through a web browser and look at the request/response header i see that it is using digest authentication, and although the web browser doesn't feed me all the details of the original exchange of information, i can see this in the request headers my browser sends back:
Authorization:
| Digest username="51191RETS", realm="MATRIX", nonce="MjAxNi0wNS0yNSAxNDo1Mzo0NC4zNjI", uri="/rets/login.ashx", algorithm=MD5, response="12ec9a9ec35586b4684925d9382e4592", opaque="0000000000000000", qop="auth", nc=00000001, cnonce="016405e4c2b627a6" |
Just figured i would pass this part along as it may or may not be relevant to understanding what is going on with the authentication.