LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Windows credentials (user and password) to login into an API???

Good morning all,

 

I'm trying to retrive data from a Web API using HTTPClient.Get vi. However, this specific API requires login credentials that are always the same of my windows login credential (windows login user and password).

I found a vi where it is possible to validate if some custom credetials match with windows credentials from System.DirectoryServices.AccountManagement.PrincipalContext (i guess!). It makes me to believe that labview can access windows user and password.

 

I would like to know if it is possible to access windows credentials and use it to login into the API without insert my credentials in labview interface. Maybe i can use some kind of certificate and use Config SSL VI but I am not confortable with certificates.

 

Can someone help me?

Thanks in advance.

0 Kudos
Message 1 of 5
(1,192 Views)

While you can get your username, there is no way to get your password in plaintext back out of Windows, as that would be a HUGE security issue if it was possible.  So if that's what you want, you're out of luck, full stop.  

 

The credentials you're mentioning that you can validate don't hold your actual password.  I don't know the full details, but I believe the way it's handled is that after a successful login Windows gets a temporary token that it holds in memory for one login session, and it just passes that token around with assorted encryption and such.  It doesn't cache your password, but it's what allows you to do things like access network drives without having to put in your password again.

 

If you were using some sort of local API there might be a way depending how it was created, but not over the web with a simple GET.

0 Kudos
Message 2 of 5
(1,150 Views)

Ok, I understand.

 

If I open the URL with my browser (Mozila), I don't need to insert the credentials. Is it possible to use a browser session, already with the token, to open the URL and get the data? 

 

Using the Web browser reference and the navigate method I’m able to access the data but it prompts a window to open/save the data, instead of giving me the data by an indicator. Is it possible to automatically save the data to the json file (without prompts the window) or access the file data without saving it? 

Thanks.

0 Kudos
Message 3 of 5
(1,134 Views)

You could try what this describes: 

 

https://forums.ni.com/t5/Example-Code/Save-File-from-URL-to-Disk/ta-p/3519166

 

Not sure if it'll work with your setup.

0 Kudos
Message 4 of 5
(1,129 Views)

I doesn't work for me

When I run the navigate method, I'm immediately getting the attached Getting File Information window and a File Download window. If I click Save, the data that I want will be saved, but I don’t want to see the prompt windows!

I want to automatically save the json file in known directory and open it afterwards or, even better, access its content without saving it.

Download All
0 Kudos
Message 5 of 5
(1,124 Views)