Currently, we have a server with PI Web API and I would like to write a php script to retrieve values from it. Our server supports Kerberos authentification as we have a LDAP Server managing user accesses. For starters, I used the following references :
- PI Web API and Kerberos Authentication via PHP https://pisquare.osisoft.com/thread/14070
- Developping with PI Web API https://pisquare.osisoft.com/docs/DOC-1940
- Php Manual for Kerberos Library
And the main lines of code I put together so far (comes from the first link) :
$username = 'domain\\username'; //for testing purpore, not staying here in the final version $password = 'password'; //for testing purpose, not staying here in the final version $url = 'https://mypiserver/piwebapi'; $ch = curl_init ( $url ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt($ch, CURLOPT_GSSAPI_DELEGATION, CURLGSSAPI_DELEGATION_FLAG); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_GSSNEGOTIATE); curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password); $result = curl_exec ( $ch );
However, I get a HTTP 401 header in the response, as the authentification failed. I tried the other solutions above, but no success so far, and I can't seem to figure out exactly where the problem comes from. I suspect the credentials to be wrongly formatted but I have no clues about how to ensure it is the correct way. Am I doing something wrong ?