rest - 在 VSTS/TFS 2017 中使用 OAuth 验证 REST API

标签 rest oauth node-modules azure-pipelines-build-task azure-devops-rest-api

我正在尝试使用 OAuth 对 REST 调用进行身份验证,但找不到与此相关的任何示例。请在这方面指导我(提供示例)。

我指的是 Microsoft 的以下文档。

https://www.visualstudio.com/en-us/docs/integrate/get-started/rest/basics

我可以使用 NTLM 对此进行验证(下面是我使用的示例)。有相同的节点库可用 ( https://www.npmjs.com/package/httpntlm )。但我需要 OAuth 类似的东西。

httpntlm.patch(options, function(err,res) {
            console.log("patch complete");
            console.log(res.body);
})

最佳答案

您可以 Authorize access to REST APIs with OAuth 2.0在 VSTS 中。目前仅适用于 VSTS,不支持 TFS2017。你也可以检查这个问题:TFS 2015 REST API Authentication .并且有一个相关的uservoice .

First, you'll register your web app and get an app ID from Visual Studio Team Services. Using that app ID, you'll send your users to Visual Studio Team Services to authorize your app to access their accounts there. Once they've done that, you'll use that authorization to get an access token for that user. When you call Visual Studio Team Services APIs on behalf of that user, you'll use that user's access token.

enter image description here

在GitHub 中实现OAuth 调用Visual Studio Team Services REST API 的C# 示例供您引用:vsts-dotnet-oauth-sample

关于rest - 在 VSTS/TFS 2017 中使用 OAuth 验证 REST API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42757039/

相关文章:

java - 空回复正文发帖放心

php - Eloquent-oauth-捕获PDO异常

node.js - 如何在公共(public)网络服务器上为 Node 应用程序安装 Node 模块?

node.js - 无法在 Ubuntu 16.04 服务器上安装 npm

javascript - 在本地存储中存储 session key

c# - 在与服务相同的解决方案中,难以在测试项目中调用在本地主机上运行的 WCF POST 服务

php - 在 OS X 上的 PHP 5 上安装 OAuth PECL 包

c# - 如何使用 C# 和 Sheet Api 访问和插入数据到 Google Spread Sheet?

javascript - 将 D3.js 7.0.0 与 Next.js 11.0.1 一起使用时,如何解决 "[ERR_REQUIRE_ESM]: Must use import to load ES Module"?

rest - PowerShell调用Sharepoint 2013 REST API更新列表项