private async void ToggleSwitch_UseHttpAuth_Toggled(object sender, RoutedEventArgs e)
        {
            if (ToggleSwitch_UseHttpAuth.IsOn)
            {
                var options = new CredentialPickerOptions()
                {
                    TargetName             = resourceLoader.GetString("Prompt_HttpAuth_Title"),
                    Caption                = resourceLoader.GetString("Prompt_HttpAuth_Title"),
                    Message                = resourceLoader.GetString("Prompt_HttpAuth_Message"),
                    CredentialSaveOption   = CredentialSaveOption.Hidden,
                    AuthenticationProtocol = AuthenticationProtocol.Basic
                };

                var result = await CredentialPicker.PickAsync(options);

                if (string.IsNullOrEmpty(result.CredentialUserName) || string.IsNullOrWhiteSpace(result.CredentialUserName))
                {
                    ToggleSwitch_UseHttpAuth.IsOn = false;
                    return;
                }
                else
                {
                    UseHttpAuth             = true;
                    HttpBasicAuthCredential = new HttpBasicAuthCredential(result.CredentialUserName, result.CredentialPassword);
                }
            }
            else
            {
                UseHttpAuth             = false;
                HttpBasicAuthCredential = new HttpBasicAuthCredential();
            }
        }
Пример #2
0
 public ApiEndPoint(string address)
 {
     Address     = address;
     UseHttpAuth = false;
     Credential  = new HttpBasicAuthCredential();
     UseProxy    = false;
     Proxy       = new ProxyInfo();
 }