Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to capture credentials / auth token from Windows credential popup dialog?

How to capture credentials / auth token from Windows credential popup dialog?

Scheduled Pinned Locked Moved C#
helptutorialsysadminhardwaresecurity
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    S p k 521
    wrote on last edited by
    #1

    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 YWRtaW46MTIzNDU2Nzg5

    How 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

    L 1 Reply Last reply
    0
    • S S p k 521

      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 YWRtaW46MTIzNDU2Nzg5

      How 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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You already posted this question at https://www.codeproject.com/Questions/5261231/How-to-capture-credentials-token-from-windows-cred[^]. Please do not repost.

      S 1 Reply Last reply
      0
      • L Lost User

        You already posted this question at https://www.codeproject.com/Questions/5261231/How-to-capture-credentials-token-from-windows-cred[^]. Please do not repost.

        S Offline
        S Offline
        S p k 521
        wrote on last edited by
        #3

        Ok. Sorry it's under the new tab. My mistake.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups