Skip to content

Instantly share code, notes, and snippets.

@lvsl-deactivated
Created May 10, 2015 16:04
Show Gist options
  • Save lvsl-deactivated/1868e9db2b41dc8f96e7 to your computer and use it in GitHub Desktop.
Save lvsl-deactivated/1868e9db2b41dc8f96e7 to your computer and use it in GitHub Desktop.
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