This is an example of the oAuth resource owner password flow using oauth2orize, express 4 and mongoDB.
git clone https://github.com/reneweb/oauth2orize_resource_owner_password_example.git
npm install
node app.js
Note: You may need to change the database configuration in the db.js file, if mongoDB doesn't run using the default port or is not running on localhost.
First of all you need to create a client in the clients collection, for example, with the mongo shell. The client should have a clientId, a clientSecret and it should be a trustedClient. For example: {"clientId" : "test", "clientSecret" : "secret", "trustedClient" : true}
curl -v -H "Content-Type: application/json" -X POST <IP>:<PORT>/users -d '{"username": "<username>", "password": "<password>"}'
curl -v -H "Content-Type: application/json" -X POST <IP>:<PORT>/oauth/token -u <clientId>:<clientSecret> -d '{"username": "<username>", "password": "<password>", "grant_type": "password"}'
curl -X GET <IP>:<PORT>/restricted -v -H "Authorization: Bearer <accessToken>"
curl -X POST <IP>:<PORT>/oauth/token -u <clientId>:<clientSecret> -v -H "Content-Type: application/json" -d '{"grant_type": "refresh_token", "refresh_token": "<refreshToken>"}'