Name: node-oauth2-server
Owner: npm
Description: Complete, compliant and well tested module for implementing an OAuth2 Server/Provider with express in node.js
Forked from: oauthjs/node-oauth2-server
Created: 2016-03-29 20:22:01.0
Updated: 2018-01-22 18:47:00.0
Pushed: 2016-03-29 20:34:24.0
Homepage: https://npmjs.org/package/node-oauth2-server
Size: 463
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Complete, compliant and well tested module for implementing an OAuth2 server in node.js.
The node-oauth2-server module is framework-agnostic but there are several wrappers available for popular frameworks such as express and koa.
Using the express wrapper (recommended):
express = require('express');
oauthserver = require('express-oauth-server');
app = express();
oauth = new oauthServer({ model: model });
use(oauth.authenticate());
get('/', function (req, res) {
s.send('Hello World');
listen(3000);
Using this module directly (for custom servers only):
Request = require('oauth2-server').Request;
oauthServer = require('oauth2-server');
oauth = new oauthServer({ model: model });
request = new Request({
aders: { authorization: 'Bearer foobar' }
h.authenticate(request)
hen(function(data) {
// Request is authorized.
atch(function(e) {
// Request is not authorized.
;
Note: see the documentation for the specification of what's required from the model.
authorization_code
(with scopes), client_credentials
, password
, refresh_token
and custom extension
grant types.Most users should refer to our express or koa examples. If you're implementing a custom server, we have many examples available:
This module has been rewritten with a promise-based approach and introduced a few changes in the model specification.
Please refer to our 3.0 migration guide for more information.