Quantcast
Channel: Http Client Protocol Issues (and other fun stuff I support)
Viewing all articles
Browse latest Browse all 140

Super secret. How to decode Base64 Basic Authentication!

$
0
0

OK, really not that secret.  Basic Authentication headers are pretty simple.  

When the server returns 401 and the header: WWW-Authenticate: Basic.  The server wants you to send the username and password in this format:  jeff:mypassword and then encode this as a Base64String.  You can encode this with this code: string secret = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("jeff:mypassword"));.  To decode a username and password from a header that you send (found in the Authorization: Basic" header) pass that string to this: string decodedSecret = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(secret));


Viewing all articles
Browse latest Browse all 140

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>