Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reneweb/oauth2orize_resource_owner_password_example
This is an example of the oAuth resource owner password flow using oauth2orize, express 4 and mongoDB.
https://github.com/reneweb/oauth2orize_resource_owner_password_example
expressjs javascript mongodb oauth2orize
Last synced: about 1 month ago
JSON representation
This is an example of the oAuth resource owner password flow using oauth2orize, express 4 and mongoDB.
- Host: GitHub
- URL: https://github.com/reneweb/oauth2orize_resource_owner_password_example
- Owner: reneweb
- License: mit
- Created: 2014-05-15T23:55:03.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-07-23T19:30:25.000Z (over 8 years ago)
- Last Synced: 2023-12-12T23:37:46.038Z (about 1 year ago)
- Topics: expressjs, javascript, mongodb, oauth2orize
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 31
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
oauth2orize_resource_owner_password_example
===========================================This is an example of the oAuth resource owner password flow using oauth2orize, express 4 and mongoDB.
##### Installation
```
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.##### Usage (with cURL)
###### 0 - Create a client
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}###### 1 - Register a user
```
curl -v -H "Content-Type: application/json" -X POST :/users -d '{"username": "", "password": ""}'
```###### 2 - Get an access token
```
curl -v -H "Content-Type: application/json" -X POST :/oauth/token -u : -d '{"username": "", "password": "", "grant_type": "password"}'
```###### 3 - Access a restricted resource using the access token
```
curl -X GET :/restricted -v -H "Authorization: Bearer "
```###### 4 - Get a new access token using the refresh token
```
curl -X POST :/oauth/token -u : -v -H "Content-Type: application/json" -d '{"grant_type": "refresh_token", "refresh_token": ""}'
```