Access TFS and visualstudio online REST Api in Electron/angularjs app

半城伤御伤魂 提交于 2020-01-03 19:29:11

问题


Whats the best way to integrate with TFS and visual studio online in Electron, using angularjs? The users can provide username, password, and URL for the server, and I want to get projects, tasks, move tasks between states, create new items etc

I have a project using angularjs and electron. I want to get my projects, tasks etc from Microsoft Team foundation server (installed on-premise) and visual studio online too. I found documentation about basic auth and oAuth to do this, but I guess oAuth works only for visual studio online, while basic auth works for both but don't let me take profile data (user's name, etc).

I see Microsoft has a c# lib with full access, but to use it in electron I would need to write a web service in c# or something like this, and it would be much better if I write my app as a standalone, working with tfs API directly.


回答1:


Update

You could use some different handlers include Basic/NTML in NodeJS API to authenticate, such as:

export function getBasicHandler(username: string, password: string): VsoBaseInterfaces.IRequestHandler {
    return new basicm.BasicCredentialHandler(username, password);
}

export function getNtlmHandler(username: string, password: string, workstation?: string, domain?: string): VsoBaseInterfaces.IRequestHandler {
    return new ntlmm.NtlmCredentialHandler(username, password, workstation, domain);
}

More details please refer this link: vsts-node-api-webapi All you need is create a login page to collect the user name / password and then pass the arguments to the handler.


Being able to have access to the data in Team Foundation Server (TFS)/Visual Studio Team Services (VSTS), mostly use two methods. The known method was to use the NuGet packages Microsoft.TeamFoundationServer.Client to perform such tasks. With the arrival of TFS 2015 and above/VSTS, Microsoft introduced a REST API that can be used to access the same data.

As on TFS2017, On-Prem TFS also supports creating personal access tokens for all users. Using the javascript code by @Elmar you can make requests to connect, edit TFS workitems from REST API. Details please refer this question: TFS 2015 REST API Authentication

But on TFS2015, there is no (PERSONAL ACCESS TOKEN). If you are working on this version, you could create a login in page, and store username and password in cookies. Then use httpntlm to do this request. Refer to this case who have similar issue with you: connecting to TFS using windows auth in electron app.




回答2:


VSTS ships clients for Javascript also.

You can find them here on the Github Repo



来源:https://stackoverflow.com/questions/46667106/access-tfs-and-visualstudio-online-rest-api-in-electron-angularjs-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!