细节:
目标版本:Windows 10 1803
最低版本:Windows 10 创意者更新
nuget:Microsoft.NETCore.UniversalWindowsPlatform v6.1.5
我有两个示例 Uwp 应用程序。两者都有使用休耕方法:
private string GetPasswordCredential()
{
PasswordVault passwordVault = new PasswordVault();
PasswordCredential passwordCredential = null;
try
{
var passwordCredentials = new List<PasswordCredential>(passwordVault.RetrieveAll());
if (passwordCredentials.Any(c => c.Resource.Equals("testResource") && c.UserName.Equals("testUserName")))
{
passwordCredential = passwordVault.Retrieve(resource: "testResource", userName: "testUserName");
}
}
catch (Exception exception)
{
var message = exception.Message;
}
if (passwordCredential == null)
{
// create credential deteils
passwordCredential = new PasswordCredential(resource: "testResource", userName: "testUserName", password: "testPassword");
// add credential details to password vault
passwordVault.Add(passwordCredential);
}
return passwordCredential.Password;
}
问题是,该方法为每个应用程序创建唯一的凭据:
我的目标是创建一个凭据详细信息(如果不存在),并在第二个应用程序运行后由第二个应用程序使用它。上述方法逻辑会进行检查,但也会为每个 App 创建全新的 Credential。我可以看到“保存者”部分的唯一区别。如何强制第二个应用程序获取/使用已经存在的凭据?
红糖糍粑
相关分类