|
1 |
| -yoloAPI |
2 |
| -=================================================================== |
3 |
| -An flask-oauthlib server example for 'Resource Owner Password Credentials Grant' |
| 1 | +# Yolo API |
| 2 | + |
| 3 | +This is a Flask-OAuthlib server example for the 'Resource Owner Password Credentials Grant' described in [RFC 6749 (Section 1.3.3)](http://tools.ietf.org/html/rfc6749#section-1.3.3). |
| 4 | + |
| 5 | +## Deployment |
| 6 | + |
| 7 | +Clone this repository and install all dependencies: |
4 | 8 |
|
5 |
| -##### Get it up and running |
6 |
| -To get it up and running clone this repository and install the dependencies. |
7 | 9 | ```bash
|
8 |
| -pip install -r requirements.txt |
| 10 | +$ pip install -r requirements.txt |
9 | 11 | ```
|
10 |
| -After this you can run the application with `python app.py`. |
11 | 12 |
|
12 |
| -##### Management |
13 |
| -At this point you should to go `http://localhost:5000` and generate a client and also create a user. |
14 |
| -Now you can use `curl` for testing the application and the access the protected resource. |
| 13 | +Once all dependencies are installed, you may run the application with `python app.py`. |
| 14 | + |
| 15 | +## User and Client Management |
| 16 | + |
| 17 | +For the example to work properly, you will need to create a client and user. You can create users and clients through the management interface available at [http://localhost:5000](http://localhost:5000). |
15 | 18 |
|
16 |
| -##### Get a Bearer token |
| 19 | +## Testing |
| 20 | + |
| 21 | +After creating a user and client, you may use curl to test the application. |
| 22 | + |
| 23 | +### Generating a Bearer Token |
17 | 24 |
|
18 | 25 | ```bash
|
19 | 26 | curl -X POST -d "client_id=9qFbZD4udTzFVYo0u5UzkZX9iuzbdcJDRAquTfRk&grant_type=password&username=jonas&password=pass" http://localhost:5000/oauth/token
|
20 | 27 | {"access_token": "NYODXSR8KalTPnWUib47t5E8Pi8mo4", "token_type": "Bearer", "refresh_token": "s6L6OPL2bnKSRSbgQM3g0wbFkJB4ML", "scope": ""}
|
21 | 28 | ```
|
22 | 29 |
|
23 |
| -##### Use the Bearer token to access the protected resource |
| 30 | +### Accessing a Protected Resource Using Retrieved Bearer Token |
| 31 | + |
24 | 32 | ```bash
|
25 | 33 | curl -H "Authorization: Bearer NYODXSR8KalTPnWUib47t5E8Pi8mo4" http://localhost:5000/yolo
|
26 |
| -YOLO!!! You made it through and accessed the protected resource |
| 34 | +YOLO! Congraulations, you made it through and accessed the protected resource! |
27 | 35 | ```
|
| 36 | + |
0 commit comments