How to capture credentials / auth token from Windows credential popup dialog?
-
Hi Experts,
I have a requirement to access a connected printer device through their embedded web server.
The device had an option to secure its details using username and password.
Once it is set, we can only communicate through "https" to that device.
Also there is windows credentials popup will come from UWP app once we initiate communication through https and wait for the user to enter the correct username and password as in web server.My requirement is we need to pass those credentials as authorization header for a POST request to that device.
eg:-
Authorization: Basic YWRtaW46MTIzNDU2Nzg5How to access those Windows credentials in UWP app. Without this authorization token, i am getting HTTP:401 unauthorized error for the POST request.
Please guide me to resolve this issue.
What I have tried:
I tried hard coding the username and password entered in the web server.
var username = usrName;
var password = pwd;
var base64String = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"));
_httpClient.AuthorizationHeader = new KeyValuePair("Basic", base64String);then in this case the POST request is successful.
Also tried the same in a separate test application. In that case after entering the credentials in the windows credentials popup the same POST request is again sending automatically with those credentials as Basic auth token.
Regards
Spk -
Hi Experts,
I have a requirement to access a connected printer device through their embedded web server.
The device had an option to secure its details using username and password.
Once it is set, we can only communicate through "https" to that device.
Also there is windows credentials popup will come from UWP app once we initiate communication through https and wait for the user to enter the correct username and password as in web server.My requirement is we need to pass those credentials as authorization header for a POST request to that device.
eg:-
Authorization: Basic YWRtaW46MTIzNDU2Nzg5How to access those Windows credentials in UWP app. Without this authorization token, i am getting HTTP:401 unauthorized error for the POST request.
Please guide me to resolve this issue.
What I have tried:
I tried hard coding the username and password entered in the web server.
var username = usrName;
var password = pwd;
var base64String = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"));
_httpClient.AuthorizationHeader = new KeyValuePair("Basic", base64String);then in this case the POST request is successful.
Also tried the same in a separate test application. In that case after entering the credentials in the windows credentials popup the same POST request is again sending automatically with those credentials as Basic auth token.
Regards
Spk -
You already posted this question at https://www.codeproject.com/Questions/5261231/How-to-capture-credentials-token-from-windows-cred[^]. Please do not repost.