我正在尝试使用 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.
在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/