passport-wiz
Advanced tools
Comparing version 1.0.0 to 1.0.1
// Load modules. | ||
var OAuth2Strategy = require('passport-oauth2') | ||
, util = require('util') | ||
, urllib = require('urllib') | ||
@@ -21,2 +22,18 @@ function Strategy(options, verify) { | ||
this._oauth2.getOAuthAccessToken = function(code, params, callback) { | ||
urllib.request(this._getAccessTokenUrl(), { | ||
dataType: 'json', | ||
contentType: 'json', | ||
data: { | ||
code: code, | ||
client_id: this._clientId, | ||
client_secret: this._clientSecret | ||
}, | ||
method: 'POST' | ||
}, function (err, body) { | ||
if (err) return callback(err) | ||
if (body.errno) return callback(new Error('obtain access_token failed')) | ||
callback(null, body.data.access_token, null, body.data) | ||
}) | ||
} | ||
} | ||
@@ -29,5 +46,14 @@ | ||
Strategy.prototype.userProfile = function(accessToken, done) { | ||
var self = this; | ||
this._oauth2.get(this._userProfileURL, accessToken, function (err, body, res) { | ||
done(err, body.data) | ||
this._oauth2._request("GET", this._userProfileURL, { | ||
'Content-Type': 'application/json', | ||
'Wiz-Access-Token': accessToken | ||
}, null, null, function (err, body) { | ||
if (err) return done(err) | ||
try { | ||
var body = JSON.parse(body) | ||
if (body.errno) return done(new Error('fetch user profile failed')) | ||
done(null, body.data) | ||
} catch (e) { | ||
done(e) | ||
} | ||
}) | ||
@@ -34,0 +60,0 @@ } |
{ | ||
"name": "passport-wiz", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Wiz authentication strategy for Passport.", | ||
@@ -33,3 +33,4 @@ "keywords": [ | ||
"dependencies": { | ||
"passport-oauth2": "1.x.x" | ||
"passport-oauth2": "1.x.x", | ||
"urllib": "^2.16.0" | ||
}, | ||
@@ -36,0 +37,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9152
59
2
+ Addedurllib@^2.16.0
+ Addedany-promise@1.3.0(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcontent-type@1.0.5(transitive)
+ Addedcopy-to@2.0.1(transitive)
+ Addeddefault-user-agent@1.0.0(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addeddigest-header@1.1.0(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedescape-html@1.0.3(transitive)
+ Addedextend-shallow@2.0.1(transitive)
+ Addedformstream@1.5.1(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.1.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhumanize-ms@1.2.1(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedis-extendable@0.1.1(transitive)
+ Addedmime@2.6.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@2.1.3(transitive)
+ Addedmz@2.7.0(transitive)
+ Addednode-hex@1.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedos-name@1.0.3(transitive)
+ Addedosx-release@1.1.0(transitive)
+ Addedpause-stream@0.0.11(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedqs@6.13.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstatuses@1.5.0(transitive)
+ Addedthenify@3.3.1(transitive)
+ Addedthenify-all@1.6.0(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedunescape@1.0.1(transitive)
+ Addedurllib@2.44.0(transitive)
+ Addedutility@1.18.0(transitive)
+ Addedwin-release@1.1.1(transitive)
+ Addedwrappy@1.0.2(transitive)