Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ Supported services

<img src="https://raw.githubusercontent.com/jed/authom/master/lib/assets/ninjablocks.ico" style="vertical-align:middle"> Ninja Blocks (by [thatguydan](https://github.com/thatguydan))

<img src="https://raw.githubusercontent.com/jed/authom/master/lib/assets/vso.png" style="vertical-align:middle"> Visual Studio Online (by [asureddi](https://github.com/asureddi))

Installation and Setup
----------------------

Expand Down
Binary file added lib/assets/vso.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 14 additions & 3 deletions lib/services/oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ OAuth2.prototype.onStart = function(req, res) {
}

OAuth2.prototype.onCode = function(req, res) {
this.token.query.code = req.url.query.code
if (this.token.host == "app.vssps.visualstudio.com"){
this.token.query.assertion = req.url.query.code
}else {
this.token.query.code = req.url.query.code
}

delete req.url.query
delete req.url.search
Expand All @@ -101,17 +105,24 @@ OAuth2.prototype.onCode = function(req, res) {
var tokenKey = this.user.tokenKey || "access_token"

this.user.query[tokenKey] = data.access_token

if (this.user.host == "oauth.reddit.com") {
this.user.headers = {"Authorization": "bearer " + data.access_token};
}

if (this.user.host == "api.stripe.com") {
delete this.user.query[tokenKey];
this.user.headers = {"Authorization": "bearer " + data.access_token};
var stripe_publishable_key = data.stripe_publishable_key;
}

if (this.user.host == "app.vssps.visualstudio.com") {
delete this.user.query[tokenKey];
this.user.headers = {"Authorization": "bearer " + data.access_token,
"accept": "application/json; api-version=1.0",
"content-type": "application/json-patch+json "};
}

this.request(this.user, function(err, user) {
if (err) return this.emit("error", req, res, err)

Expand Down
44 changes: 44 additions & 0 deletions lib/services/vso.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
var OAuth2 = require("./oauth2")
, util = require("util")

function vso(options) {
this.code.query = {
client_id: options.id,
response_type: "Assertion",
scope: options.scope
}

this.token.query = {
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
client_assertion: options.secret,
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
assertion: ""
}

this.user.query = {}

this.on("request", this.onRequest.bind(this))

OAuth2.call(this, options)
}

util.inherits(vso, OAuth2)

vso.prototype.code = {
protocol: "https",
host: "app.vssps.visualstudio.com",
pathname: "/oauth2/authorize"
}

vso.prototype.token = {
method: "POST",
host: "app.vssps.visualstudio.com",
path: "/oauth2/token",
headers: { "Content-Type": "application/x-www-form-urlencoded" }
}

vso.prototype.user = {
host: "app.vssps.visualstudio.com",
path: "/_apis/profile/profiles/me?api-version=1.0"
}
module.exports = vso