0 Replies Latest reply: Jun 15, 2017 4:40 AM by John Schmidt RSS

    Qlik Sense Authentication with PHP

    John Schmidt

      Hi everyone,

       

      i'm afraid i got stuck with trying to use the Sense API using PHP.

      I tried what i wanted to do with Postman before and it works like a charm.

      Doing the same with PHP i fail to authenticate - one reason is surely that im not an expert in web authentication methods.

      However, i'm hoping that somebody might be able to help me out.

       

      I'm trying to get a simple list of the apps available:

      https://my-server/qrs/app?xrfkey=sjdk87ezfhcn7654


      Even for people who are not firm with PHP i think you can get the idea with the below code.

      The problem is, that i get a response containing a Sense login form.


      Anybody an idea what im doing wrong?


      ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


      $client = new GuzzleHttp\Client(
        [
              'base_uri' => 'https://my-server/qrs/',
              'verify' => false,
              'defaults' =>
      [
                        'headers' => [
                             'x-qlik-xrfkey' => 'sjdk87ezfhcn7654',
                             'X-Qlik-User'  => 'UserDirectory=NET;UserId=schmidtj',
                        ]
               ]
        ]
      );

      try
      {
         $response = $client->request('GET', 'app?xrfkey=sjdk87ezfhcn7654',  [
              'auth' => ['domain\user', 'password', 'ntlm']
          ]);
      }
      catch (GuzzleHttp\Exception\RequestException $e) {
            echo $e->getRequest() . "\n";
            if ($e->hasResponse()) {
           echo $e->getResponse() . "\n";
        }
      }