Last active
August 29, 2015 14:22
-
-
Save thomseddon/66d95e2e2658b0911ca9 to your computer and use it in GitHub Desktop.
This file contains 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
# Test: | |
$ curl http://127.0.0.1:3000 | |
# With debug set to true | |
$ node test.js | |
OAuth2Error: The access token was not found | |
at OAuth2Error (/home/thom/Dev/node/t/node_modules/oauth2-server/lib/error.js:30:12) | |
at Authorise.getBearerToken (/home/thom/Dev/node/t/node_modules/oauth2-server/lib/authorise.js:70:17) | |
at run (/home/thom/Dev/node/t/node_modules/oauth2-server/lib/runner.js:15:14) | |
at runner (/home/thom/Dev/node/t/node_modules/oauth2-server/lib/runner.js:19:5) | |
at new Authorise (/home/thom/Dev/node/t/node_modules/oauth2-server/lib/authorise.js:45:3) | |
at /home/thom/Dev/node/t/node_modules/oauth2-server/lib/oauth2server.js:70:12 | |
at Layer.handle [as handle_request] (/home/thom/Dev/node/t/node_modules/express/lib/router/layer.js:82:5) | |
at next (/home/thom/Dev/node/t/node_modules/express/lib/router/route.js:110:13) | |
at Route.dispatch (/home/thom/Dev/node/t/node_modules/express/lib/router/route.js:91:3) | |
at Layer.handle [as handle_request] (/home/thom/Dev/node/t/node_modules/express/lib/router/layer.js:82:5) | |
^C | |
# With debug set to false | |
$ node test.js | |
^C |
This file contains 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 express = require('express'), | |
bodyParser = require('body-parser'), | |
oauthserver = require('oauth2-server'); | |
var app = express(); | |
app.use(bodyParser.urlencoded({ extended: true })); | |
app.use(bodyParser.json()); | |
app.oauth = oauthserver({ | |
model: {}, | |
grants: ['password'], | |
debug: false | |
}); | |
app.all('/oauth/token', app.oauth.grant()); | |
app.get('/', app.oauth.authorise(), function (req, res) { | |
res.send('Secret area'); | |
}); | |
app.use(app.oauth.errorHandler()); | |
app.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment