11# Auth0 + Python + Flask API Seed
2+
23This is the seed project you need to use if you're going to create a Python + Flask API.
34If you just want to create a Regular Python WebApp, please
45check [ this project] ( https://github.com/auth0-samples/auth0-python-web-app/tree/master/01-Login )
56
67Please check our [ Quickstart] ( https://auth0.com/docs/quickstart/backend/python ) to better understand this sample.
78
89# Running the example
10+
911In order to run the example you need to have ` python ` and ` pip ` installed.
1012
1113You also need to set your Auth0 Domain and the API's audience as environment variables with the following names
12- respectively: ` AUTH0_DOMAIN ` and ` API_ID ` , which is the audience of your API. You can find an example in the
14+ respectively: ` AUTH0_DOMAIN ` and ` AUTH0_AUDIENCE ` , which is the audience of your API. You can find an example in the
1315` env.example ` file.
1416
1517For that, if you just create a file named ` .env ` in the directory and set the values like the following,
@@ -18,24 +20,24 @@ the app will just work:
1820``` bash
1921# .env file
2022AUTH0_DOMAIN=example.auth0.com
21- API_ID =YOUR_API_AUDIENCE
23+ AUTH0_AUDIENCE =YOUR_API_AUDIENCE
2224```
2325
24- Once you've set those 2 enviroment variables:
26+ Once you've set those 2 environment variables:
2527
26281 . Install the needed dependencies with ` pip install -r requirements.txt `
27292 . Start the server with ` python server.py `
28- 3 . Try calling [ http://localhost:3010/ping ] ( http://localhost:3010/ping )
30+ 3 . Try calling [ http://localhost:3010/api/public ] ( http://localhost:3010/api/public )
2931
3032# Testing the API
3133
32- You can then try to do a GET to [ http://localhost:3010/secured/ping ] ( http://localhost:3010/secured/ping ) which will
34+ You can then try to do a GET to [ http://localhost:3010/api/private ] ( http://localhost:3010/api/private ) which will
3335throw an error if you don't send an access token signed with RS256 with the appropriate issuer and audience in the
3436Authorization header.
3537
3638You can also try to do a GET to
37- [ http://localhost:3010/secured /private/ping ] ( http://localhost:3010/secured /private/ping ) which will throw an error if
38- you don't send an access token with the scope ` read:agenda ` signed with RS256 with the appropriate issuer and audience
39+ [ http://localhost:3010/api /private-scoped ] ( http://localhost:3010/api /private-scoped ) which will throw an error if
40+ you don't send an access token with the scope ` read:messages ` signed with RS256 with the appropriate issuer and audience
3941in the Authorization header.
4042
4143# Running the example with Docker
@@ -44,4 +46,4 @@ In order to run the sample with [Docker](https://www.docker.com/) you need to ad
4446to the ` .env ` filed as explained [ previously] ( #running-the-example ) and then
4547
46481 . Execute in command line ` sh exec.sh ` to run the Docker in Linux, or ` .\exec.ps1 ` to run the Docker in Windows.
47- 2 . Try calling [ http://localhost:3010/ping ] ( http://localhost:3010/ping )
49+ 2 . Try calling [ http://localhost:3010/api/public ] ( http://localhost:3010/api/public )
0 commit comments