简体   繁体   中英

Windows.Web.Http Authentication with a blank username / only password

I'm new to developing Windows 10 Universal Apps. I need to authenticate with Windows.Web.Http with a blank/empty username and only with a password. If I use a empty string or null I've got an exception on creating the credentials.

Any idea?

Ok, i've got it by myself:

First I tried using (empty username throws Invalid Argument exception):

filter.ServerCredential = new Windows.Security.Credentials.PasswordCredential(uri.ToString(), username, pass);

Now I am using:

var buffer = Windows.Security.Cryptography.CryptographicBuffer.ConvertStringToBinary(username + ":" + pass, Windows.Security.Cryptography.BinaryStringEncoding.Utf8);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM