执行Restapi Azure DevOps服务 - 用户名&身份验证密码没有pat

发布于 2025-02-08 18:51:38 字数 865 浏览 3 评论 0 原文

我可以使用用户/密码组合将RESTAPI运行到Azure DevOps服务吗?

简短答案否。 - 请参阅标记答案的说明,

我试图找到一种使RESTAPI在没有PAT的情况下工作或从当前登录信息中创建令牌的方法,并且未能通过

以下代码返回401:

using System.Net;

byte[] bytes = System.Text.Encoding.ASCII.GetBytes("user:password");
string patEncoded = Convert.ToBase64String(bytes);

var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://dev.azure.com/<ORG>/_apis/wit/workitems/22289?api-version=6.0");
httpWebRequest.Headers.Add("Authorization", "Basic " + patEncoded);

httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "GET";

var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();



var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

任何建议都非常感谢

  1. 我不想创建应用程序并将其注册在租户上。

Can i Use User/Password combination to run RestAPI to Azure DevOps Services?

Short answer NO. - see explanation at marked answer

I tried to find a way to get RestAPI working without PAT or Create a Token from Current Login Info and failed

The following Code Return 401:

using System.Net;

byte[] bytes = System.Text.Encoding.ASCII.GetBytes("user:password");
string patEncoded = Convert.ToBase64String(bytes);

var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://dev.azure.com/<ORG>/_apis/wit/workitems/22289?api-version=6.0");
httpWebRequest.Headers.Add("Authorization", "Basic " + patEncoded);

httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "GET";

var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();



var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

Any Advice is much appreciated

  1. I do not want to create an app and register it on the tenant .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜警司 2025-02-15 18:51:38

身份验证您的Web应用程序用户以供REST API访问,因此您的应用程序不会继续询问用户名和密码。 Azure Devops Services使用OAuth 2.0协议授权您的应用程序为用户使用并生成访问令牌。当您从应用程序中调用RETS API时,请使用此令牌。

对于身份验证机制,REST API正在使用提及的身份验证机制是身份验证。

用户名&amp;密码:自2020年3月2日开始,Azure DevOps不再支持替代凭据身份验证。这是

Authenticate your web app users for REST API access, so your app doesn't continue to ask for usernames and passwords. Azure DevOps Services uses the OAuth 2.0 protocol to authorize your app for a user and generate an access token. Use this token when you call the REST APIs from your application.

For the Authentication mechanism, REST API is using the mention-aboved authentication mechanism to be authentication.

userName & password: Azure DevOps no longer supports Alternate Credentials authentication since the beginning of March 2, 2020. Here is the document.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文