egg-oauth2-server
Install
$ npm i egg-oauth2-server --save
Usage
// {app_root}/config/plugin.jsexportsoauth2Server = enable: true package: 'egg-oauth2-server'; // {app_root}/app/router.jsappall'/user/grant' appoauth;app;
Configuration
// {app_root}/config/config.default.jsmodule { const exports = {}; exportsoauth2Server = debug: configenv === 'local' grants: 'password' ; return exports;};
See test/fixtures/apps/oauth2-server-test/config/config.unittest.js for reference.
Full description see https://www.npmjs.com/package/oauth2-server.
Implementation Example
A simple implementation of password mode OAuth 2.0 server, see test/fixtures/apps/oauth2-server-test/app/extend/oauth.js
// {app_root}/app/extend/oauth.js'use strict'; module { const model = {}; model {}; model {}; model {}; // only for password mode model {}; model {}; return model;};
Full description see https://www.npmjs.com/package/oauth2-server.
app.oauth.grant()
lifecycle
password mode getClient
--> grantTypeAllowed
--> getUser
--> saveAccessToken
app.oauth.authorise()
lifecycle
password mode Only getAccessToken
Questions & Suggestions
Please open an issue here.