我正在开发一个项目,我需要在Visual Studio Online实例上创建工作项。我正在使用个人访问令牌。这会将CreatedBy设置为我的名字(预期行为)。我正在考虑使用Oauth2;但是,我不确定是否有办法执行此服务器到服务器(非交互式)?有什么建议吗?
var personalAccessToken = "PAT Value fro Config"; HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", "", personalAccessToken)))); return client;
PAT是在用户的安全上下文中创建的。我需要找到一种方法来使用Oauth,而不必涉及UI。所以我正在寻找Server-to-Server Auth。
object[] patchDocument = new object[5]; patchDocument[0] = new { op = "add", path = "/fields/System.Title", value = bugTitle }; patchDocument[1] = new { op = "add", path = "/fields/Microsoft.VSTS.TCM.ReproSteps", value = bugReproSteps }; patchDocument[2] = new { op = "add", path = "/fields/Microsoft.VSTS.Common.Priority", value = "1" }; patchDocument[3] = new { op = "add", path = "/fields/Microsoft.VSTS.Common.Severity", value = "2 - High" }; patchDocument[4] = new { op = "add", path = "/fields/System.IterationPath", value = deserializeIteration }; //System.IterationPath string postUrl = $"{_vsoInstanceUrl}/DefaultCollection/ProjectName/_apis/wit/workitems/$Bug?api-version=1.0"; await ExecutePatch(patchDocument.ToArray(), postUrl, "application/json-patch+json");