Created
May 10, 2015 16:04
-
-
Save lvsl-deactivated/1868e9db2b41dc8f96e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var server = nodeOauth2Server({ | |
model: modelHandlers, | |
grants: ['password', 'refresh_token'], | |
debug: false, | |
refreshTokenLifetime: null, // never expire refresh token | |
passthroughErrors: true | |
}); | |
module.exports = { | |
grantWrap: function oauthGrantWrap(req, res, next) { | |
var grantInstace = server.grant(); | |
// hack to prevent ugly http error responses | |
grantInstace(req, res, function grantErrorHandler(err) { | |
if (err) { | |
res.status(err.code || 500); | |
res.json(err); | |
} | |
}); | |
}, | |
authoriseWrap: function oauthGrantWrap(req, res, next) { | |
var authInstace = server.authorise(); | |
// hack to prevent ugly http error responses | |
authInstace(req, res, function authErrorHandler(err) { | |
if (err) { | |
res.status(err.code || 500); | |
res.json(err); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment