This project is a demo for OAuth2-server package usage with grant_type of authorization_code
-
I use the mongodb for the oauth2-server model, so you should run a local mongodb server first.
-
And then create a database (I use the name of test).
-
Add a client document to
oauthclients
collection like below:{ "_id" : ObjectId("5d0904b86ead30545165865d"), "clientId" : "clientid123", "clientSecret" : "clientsecret123", "grants" : [ "authorization_code", "refresh_token" ], "redirectUris" : [ "http://localhost:3001/authCallback" ] }
more collection name see here
-
start the client and oauth2 server
- install
yarn
ornpm init
- client
yarn client
ornpm run client
- server
yarn start
ornpm start
- install
- oauth2-server
- package
npm install oauth2-server
- The OAuth 2.0 Authorization Framework rfc6749