Skip to content

Commit c7885f5

Browse files
committed
Update README.md to match new sample code
1 parent a3f0611 commit c7885f5

File tree

2 files changed

+17
-29
lines changed

2 files changed

+17
-29
lines changed

README.md

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,34 @@
22

33
This is the seed project you need to use if you're going to create an API using FastAPI in Python and Auth0. If you just want to create a Regular Python WebApp, please check [this project](https://github.com/auth0-samples/auth0-python-web-app/tree/master/01-Login)
44

5-
<!--
6-
Please check our [Quickstart](https://auth0.com/docs/quickstart/backend/python) to better understand this sample.
7-
-->
8-
95
## Running the example
106

117
In order to run the example you need to have `python3` (any version higher than `3.6`) and `pip3` installed.
128

139
### Configuration
1410

15-
This app is prepared to be deployed to a production environment which means you can create environment variables for running it both on production or development envs let's see how that looks.
11+
### Configuration
1612

17-
There are two ways you can configure and fill the necessary variables:
13+
The configuration you'll need is mostly information from Auth0, you'll need both the tentant domain and the API information.
1814

19-
1. Creating environment variables; or
20-
1. Creating a `.config` file to hold said variables values
15+
This app reads its configuration information from a `.config` file by default.
2116

22-
For the **first** approach you'll need 4 variables (remember to update the values accordingly):
17+
To create a `.config` file you can copy the `.example.config` file and fill the values accordingly:
2318

2419
```console
25-
export DOMAIN='your.domain.auth0.com'
26-
export API_AUDIENCE='your.api.audience'
27-
export ALGORITHMS='RS256'
28-
export ENV='variables'
20+
cp .example.config .config
21+
# update the config file for the correct values
22+
export ENV='.config'
2923
```
3024

31-
For the **second** approach you can copy the `.example.config` file and fill the values accordingly:
25+
You can change this behavior by setting the following environment variables (remember to update the values accordingly):
3226

3327
```console
34-
cp .example.config .config
35-
# update the config file for the correct values
36-
export ENV='.config'
28+
export ENV='variables'
29+
export DOMAIN='your.domain.auth0.com'
30+
export API_AUDIENCE='your.api.audience'
31+
export ISSUER='https://your.domain.auth0.com'
32+
export ALGORITHMS='RS256'
3733
```
3834

3935
### Spin up the server
@@ -93,13 +89,3 @@ curl -X 'GET' \
9389
-H 'accept: application/json' \
9490
-H 'Authorization: Bearer <FILL YOUR TOKEN WITH SCOPES HERE>'
9591
```
96-
97-
<!--
98-
## Running the example with Docker
99-
100-
In order to run the sample with [Docker](https://www.docker.com/) you need to add the `AUTH0_DOMAIN` and `API_ID`
101-
to the `.env` filed as explained [previously](#running-the-example) and then
102-
103-
1. Execute in command line `sh exec.sh` to run the Docker in Linux, or `.\exec.ps1` to run the Docker in Windows.
104-
2. Try calling [http://localhost:8000/api/public](http://localhost:8000/api/public)
105-
-->

application/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def verify(self):
4444
).key
4545
except jwt.exceptions.PyJWKClientError as error:
4646
return {"status": "error", "msg": error.__str__()}
47+
except jwt.exceptions.DecodeError as error:
48+
return {"status": "error", "msg": error.__str__()}
4749

4850
try:
4951
payload = jwt.decode(
@@ -53,7 +55,7 @@ def verify(self):
5355
audience=self.config["API_AUDIENCE"],
5456
issuer=self.config["ISSUER"],
5557
)
56-
except:
58+
except Exception as e:
5759
return {"status": "error", "message": str(e)}
5860

5961
if self.scopes:
@@ -68,7 +70,7 @@ def verify(self):
6870

6971
return payload
7072

71-
def _check_claims_with_expected(self, payload, claim_name, claim_type, expected_value):
73+
def _check_claims(self, payload, claim_name, claim_type, expected_value):
7274

7375
instance_check = isinstance(payload[claim_name], claim_type)
7476
result = {"status": "success", "status_code": 200}

0 commit comments

Comments
 (0)