问题描述
调用GitHttpClient.CreateAnnotatedTagAsync时,即使我的凭据有效,我仍然收到“ VS30063:您无权访问https://dev.azure.com”。
这是我的代码:
var vssConnection = new VssConnection(new Uri("ORG_URI"),new VssBasicCredential(string.Empty,"PAT"));
var gitClient = vssConnection.GetClient<GitHttpClient>();
var tag = new GitAnnotatedTag
{
Name = "tagname",Message = "A new tag",TaggedBy = new GitUserDate
{
Name = "Name",Email = "Email",Date = DateTime.Now,ImageUrl = null
},ObjectId = "SHA",Taggedobject = new GitObject
{
ObjectId = "SHA",ObjectType = GitObjectType.Commit
},Url = string.Empty
};
var sourceRepo = await gitClient.GetRepositoryAsync("PROJECT",repoName);
// This call works
var tags = await gitClient.GetTagRefsAsync(sourceRepo.Id);
// The tag is printed to the console
Console.WriteLine(tags.First().Name);
// This throws "VS30063: You are not authorized to access https://dev.azure.com"
await gitClient.CreateAnnotatedTagAsync(tag,"PROJECT",sourceRepo.Id);
@H_502_6@