phpSPO icon indicating copy to clipboard operation
phpSPO copied to clipboard

authCtx->acquireTokenForUser => DOMXPath::query(): Undefined namespace prefix

Open josepichu opened this issue 6 years ago • 6 comments

From today, I have problems trying to connect in the following line:

$this->authCtx->acquireTokenForUser(Config::get('sharePoint.user'),Config::get('sharePoint.pwd'));

It seems that there has been some Oauth update from the provider.

the error is 'DOMXPath::query(): Undefined namespace prefix'

Has it happened to someone?

UPDATE: I've been debugging and come up with the following code in processSecurityTokenResponse method of SamlTokenProvider class:

` protected function processSecurityTokenResponse($response) { var_dump($response);die;

    $xml = new \DOMDocument();
	
    $xml->loadXML($response);

    $xpath = new \DOMXPath($xml);

    if ($xpath->query("//S:Fault")->length > 0) {
		var_dump($xpath->query("//S:Fault"));die;
        $nodeErr = $xpath->query("//S:Fault/S:Detail/psf:error/psf:internalerror/psf:text")->item(0);
		
		
		
        throw new \Exception($nodeErr->nodeValue);
    }
    $nodeToken = $xpath->query("//wsse:BinarySecurityToken")->item(0);
    if (empty($nodeToken)) {
        throw new \RuntimeException('Error trying to get a token, check your URL or credentials');
    }

    return $nodeToken->nodeValue;
}`

the var_dump print:

string(1485) "10x800488000x80048823PROD-AMS1-016.ProdSlices rid:f4935dca-30ba-4d1c-8955-ded41b4e0b00S:Senderwst:FailedAuthenticationAuthentication Failure0x800488230x80048823AADSTS70002: Error validating credentials. AADSTS50053: You've tried to sign in too many times with an incorrect user ID or password."

However, i can sigin without any problems in sharePoint website with the same credentials.

Any Ideas?

thanks you.

josepichu avatar Jul 13 '18 13:07 josepichu

Having the same issue now in our environments. Any insight on this?

ErrorException in SamlTokenProvider.php line 109: DOMXPath::query(): Undefined namespace prefix in SamlTokenProvider.php line 109

We get one of 2 sets of errors. Set 1: AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password Set 2: AADSTS70002: Error validating credentials. AADSTS50053: You've tried to sign in too many times with an incorrect user ID or password

However username and password are correct and we can sign into the SharePoint website with the same credentials without any issues. Started in the time frame of 7/19 - 7/22

UPDATE We updated to the most recent package version via:

composer require vgrem/php-spo:2.2.0
composer dump-autoload
php artisan cache:clear

And our application started working again correctly (also made sure username/password was correct)

almann87 avatar Jul 24 '18 15:07 almann87

Have the same issue. Tried to update to the latest version phpSPO but on line Fatal error: Uncaught Error: Call to a member function item() on boolean in /src/Runtime/Auth/SamlTokenProvider.php:253 Last week (before 18) everything was working correctly.

trikem avatar Jul 24 '18 16:07 trikem

I am also having this issue and updating has not fixed the update. I can see microsoft has issued an update on the 18th this seems to correlate with the timeframe that I have observed and reported above. Any other fixes for this?

However username and password are correct and we can sign into the SharePoint website with the same credentials without any issues. Started in the time frame of 7/19 - 7/22

uswross avatar Jul 25 '18 18:07 uswross

I changed line 109 in /src/Runtime/Auth/SamlTokenProvider.php to $nodeErr = $xpath->query("//S:Fault/S:Detail")->item(0); This seems to conform to a change in the error response xml format

danieladavis avatar Aug 06 '18 22:08 danieladavis

Have the same issue Any other fixes for this?

Sofiaaccount avatar Aug 07 '18 10:08 Sofiaaccount

I changed line 109 in /src/Runtime/Auth/SamlTokenProvider.php to $nodeErr = $xpath->query("//S:Fault/S:Detail")->item(0); This seems to conform to a change in the error response xml format

This worked for me as well.

jschwartzmtn avatar Apr 11 '19 17:04 jschwartzmtn