https://github.com/reneweb/oauth2orize_client_credentials_example
This is an example of the oAuth client credentials flow using oauth2orize, express 4 and mongoDB.
https://github.com/reneweb/oauth2orize_client_credentials_example
Last synced: over 1 year ago
JSON representation
This is an example of the oAuth client credentials flow using oauth2orize, express 4 and mongoDB.
- Host: GitHub
- URL: https://github.com/reneweb/oauth2orize_client_credentials_example
- Owner: reneweb
- License: mit
- Created: 2014-05-20T21:28:11.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-05-30T12:37:41.000Z (about 12 years ago)
- Last Synced: 2025-03-29T12:11:41.462Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 172 KB
- Stars: 12
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
oauth2orize_client_credentials_example
======================================
This is an example of the oAuth client credentials flow using oauth2orize, express 4 and mongoDB.
##### Installation
```
git clone https://github.com/reneweb/oauth2orize_client_credentials_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 and a clientSecret.
For example:
{"clientId" : "test", "clientSecret" : "secret"}
###### 1 - Get an access token
```
curl -v -H "Content-Type: application/json" -X POST :/oauth/token -u : -d '{"grant_type": "client_credentials"}'
```
###### 2 - Access a restricted resource using the access token
```
curl -X GET :/restricted -v -H "Authorization: Bearer "
```