我们正在迁移一些过去在本地 TFS 服务器上运行但现在需要在 Azure DevOps(以前是团队服务)上运行的代码。我使用的凭据已经过验证,可以成功向我们的 DevOps 组织实例进行身份验证,但在引用
Microsoft.TeamFoundationServer.ExtendedClient
NuGet 包总是导致TF30063: You are not authorized to access https://dev.azure.com/<myOrg>
下面发布的代码用于通过非交互式身份验证进行身份验证。我是否需要使用不同的身份验证机制或不同的凭据类型才能使其正常工作?
System.Net.NetworkCredential networkCredential = new System.Net.NetworkCredential(_userName, DecryptedPassword, _domain);
try
{
// Create TeamFoundationServer object
_teamFoundationCollection = new TfsTeamProjectCollection(_serverUrl, networkCredential);
_teamFoundationCollection.Authenticate();
}
catch (Exception ex)
{
// Not authorized
throw new TeamFoundationServerException(ex.Message, ex.InnerException)
}