我想使用 Http 身份验证获取私人提要中的包列表。这是我的代码,当我调用 ListPlugins 方法时出现 401 错误,我该如何设置凭据?
public class PluginManager
{
private readonly string _pluginFolder;
private readonly IPackageRepository _packageRepository;
private readonly PackageManager _packageManager;
public PluginManager(string plugInFolder, string packageRepositoryAddres)
{
_pluginFolder = plugInFolder;
_packageRepository = PackageRepositoryFactory.Default.CreateRepository(packageRepositoryAddres);
_packageManager = new PackageManager(_packageRepository, _pluginFolder);
}
public IEnumerable<PluginModel> ListPlugins()
{
IPackage dummy = null;
var result = _packageManager.SourceRepository.GetPackages()
.OrderBy(p => p.Id)
.ToList()
.Select(p => new PluginModel()
{
PackageId = p.Id,
PackageVersion = p.Version.ToString(),
PackageDescription = p.Description,
IsInstalled = _packageManager.LocalRepository.TryFindPackage(p.Id, p.Version, out dummy)
})
.ToList();
return result;
}
public void Install(string packageId, string packageVersion)
{
_packageManager.InstallPackage(packageId, new SemanticVersion(packageVersion));
}
public void Uninstall(string packageId, string packageVersion)
{
_packageManager.UninstallPackage(packageId, new SemanticVersion(packageVersion));
}
}