3

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.

Jean Robert
  • 749
  • 1
  • 7
  • 20

2 Answers2

2

VSTS ships clients for Javascript also.

You can find them here on the Github Repo

Harshil Lodhi
  • 7,274
  • 1
  • 33
  • 42
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.

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • can I use the nodejs client to connect using username and password? i want to have a login page where user inputs URL, username and password. And will it works for both TFS on-premise and VSTS? – Jean Robert Oct 11 '17 at 14:03
  • 1
    @JeanRobert Found something new, I think this will work for both TFS and VSTS. you could also use some different handlers include `Basic/NTML` in NodeJS API to authenticate tfs/VSTS. All you need then is creating a login page to collect the user name / password and pass the arguments to the handler. Not familiar with Electron app, but I think it's not a hard thing. Details please see my update answer. – PatrickLu-MSFT Oct 12 '17 at 10:09
  • I guess this is the best way to do it. I see theres many different handlers i could use. Thanks a lot!!! – Jean Robert Oct 12 '17 at 18:20
  • I can't find how to get my projects using personal access token as i cant find how yo get my user id ;x is oAuth the only option for this? – Jean Robert Oct 14 '17 at 21:20
  • @JeanRobert For creating personal access token in TFS2017, you could refer this blog https://learn.microsoft.com/en-us/vsts/accounts/use-personal-access-tokens-to-authenticate just make sure enable IIS Basic Authentication invalidates using PATs for TFS. To use Node.js API, personal access token to authenticate TFS, please refer **Create a connection** part in this link: https://github.com/Microsoft/vsts-node-api Sorry not got your point. What's use ID are you going to get and the detail use for it? – PatrickLu-MSFT Oct 16 '17 at 14:42
  • 1
    Im already with my personal access token created and connected to vsts but, in my project, i need to be able to assign tasks to me (user logged). Can I get the user logged using personal access token? in documentation is said that the profiles endpoints only can be requested using oAuth authentication. – Jean Robert Oct 16 '17 at 15:59
  • @JeanRobert Personal access tokens essentially are alternate passwords that you create in a secure way using your normal authentication, and PATs can have expiration dates, limited scopes (for example, only certain REST APIs or command line operations are valid), and specific VSTS accounts. I'm afraid you could not get the user logged using personal access token. – PatrickLu-MSFT Oct 16 '17 at 16:52
  • Ok. I decided to go with a webapi in .net. Its already working fine and much more easily. Thanks for all efforts in help me! – Jean Robert Oct 16 '17 at 17:12