Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
New Contributor

.NET SDK: AsDirectConnection returns 'Authentication failed.'

I'm trying to connect to our Qlik Sense server via the .NET SDK. To retrieve the list of apps and sheets.

After creating the connection I'm using the location to retrieve the actual Qlik version as a test. When using the "AsNtlmUserViaProxy" function I get the correct version of Qlik, but when I'm trying to connect via the function "AsDirectConnection" I get the exception "Authentication failed."

I exported a certificate from QMC and installed the client and root certificate on my Windows machine.


I'm using the following code to create the location:


var uri = new Uri("https://***");            
ILocation location = Location.FromUri(uri);

var certificatPWD = "****";

byte[] rawData = File.ReadAllBytes(@"c:\cert\client.pfx");

var x509 = new X509Certificate2(rawData, certificatPWD, X509KeyStorageFlags.MachineKeySet);
var certificateCollection = new X509Certificate2Collection

location.AsDirectConnection(userDirectory: "DOMAIN", userId: "USERNAME", certificateCollection: certificateCollection);



What causes this exception and how to fix this?

Tags (2)
Labels (3)
1 Reply

Re: .NET SDK: AsDirectConnection returns 'Authentication failed.'

Did you add the engine port to the uri? If you do a direct connection, then you'll need the port. It's typically 4747. So something like https://my.uri:4747

By the way, with the latest versions of the SDK there is a class for doing that certificate loading you are doing. You could write something like this (you'll need to create a secure string of the password though):

var ccertificateCollection = CertificateManager.LoadCertificateFromDirectory(@"c:\cert", certificatePWD);