LeanKit-Labs/vso-client — pull request #23 by bfcamara (2014-09-24 08:51:18+00:00)
Title: Support for WRAP tokens

This PR aims to **support to use WRAP tokens, which will allow to consume VSO REST API using service account identies**.

Summarizing, this PR adds:
- **a new method getWrapToken** to get a new WRAP token from ACS for the specified account URL, username, and password
- **a new method createWrapClient** to create a VSO client instance based on a WRAP token

Here is a code snippet illustrating the usage of these new methods

```javascript
var vsoClient = require('./public/vso-client.js');
var util = require('util');

var accountUrl = 'https://your_account_name.visualstudio.com';
var username = 'your_account_service_username;
var password = 'your_account_service_password;

vsoClient.getWrapToken(accountUrl, username, password, function (err, data, resp) {
if (err) {
console.log('Error getting a WRAP token:' + util.inspect(err));
return;
}

var accessToken = data.wrap_access_token;
var client = vsoClient.createWrapClient(accountUrl, 'DefaultCollection', accessToken);
//Now you can use the client as usually
client.getProjects(function (err, data) {
if (err) {
console.log('Error getting a projects:' + util.inspect(err));
return;
}
console.log('Here are your projects:\n' + util.inspect(data));
});
});
```