All Projects → reneweb → oauth2orize_authorization_grant_example

reneweb / oauth2orize_authorization_grant_example

Licence: MIT license
This is an example of the oAuth authorization grant flow using oauth2orize, express 4 and mongoDB.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to oauth2orize authorization grant example

Oauth2orize
OAuth 2.0 authorization server toolkit for Node.js.
Stars: ✭ 3,273 (+13537.5%)
Mutual labels:  oauth2orize

oauth2orize_authorization_grant_example

This is an example of the oAuth authorization grant flow using oauth2orize, express 4 and mongoDB.

Installation
git clone https://github.com/reneweb/oauth2orize_authorization_grant_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 - Register a client

Navigate to /client/registration. Register a new client.

1 - Register a user

Navigate to /registration. Register a new user.

2 - Get authorization token

Navigate to /oauth/authorization?clientId=<clientId>&redirectUri=<redirectUri>&responseType=code. Login with username and password. Then allow the client to access your account. If everything works the authorization code is returned.

3 - Exchange the authorization code for a access token
curl  -v  -H "Content-Type: application/json" -X POST <IP>:<PORT>/oauth/token -u <clientId>:<clientSecret> -d '{"code": "<authorization_code>", "grant_type": "authorization_code"}'
4 - Access a restricted resource using the access token
curl -X GET <IP>:<PORT>/restricted -v -H "Authorization: Bearer <accessToken>"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].