@@ -16,15 +16,17 @@ cd auth0-python-web-app
16
16
``` bash
17
17
pip install -r requirements.txt
18
18
```
19
- ## Step 4: Using Auth0 SDK for Authentication
20
- Before implementing the OAuth flow, understand how to use the Auth0 SDK for direct authentication:
19
+
20
+ ## Step 4: Using Auth0-Python SDK for Client Intialization
21
+
21
22
``` python
22
23
from auth0.authentication import GetToken
23
24
# Initialize the GetToken object with your Auth0 domain and client credentials
24
25
auth_client = GetToken(' your-domain.us.auth0.com' , ' your-client-id' , client_secret = ' your-client-secret' )
25
26
```
27
+
26
28
## Step 5: Modify the Login Route
27
- Replace the standard OAuth login route with a custom implementation that supports federated access:
29
+ Replace the standard Authlib login route with a custom implementation that supports federated access:
28
30
``` python
29
31
@app.route (" /login" )
30
32
def login ():
@@ -56,6 +58,7 @@ def login():
56
58
)
57
59
return redirect(auth_url)
58
60
```
61
+
59
62
## Step 6: Update Callback Handler
60
63
Update the callback handler to work with the custom login route:
61
64
``` python
@@ -83,6 +86,7 @@ def callback():
83
86
" refresh_token" : token_response.get(" refresh_token" ),
84
87
" id_token" : token_response.get(" id_token" )
85
88
}
89
+
86
90
# Get user info
87
91
user_info_url = f " https:// { env.get(' AUTH0_DOMAIN' )} /userinfo "
88
92
user_info_headers = {" Authorization" : f " Bearer { token_response.get(' access_token' )} " }
@@ -91,6 +95,7 @@ def callback():
91
95
session[" user" ] = user_info
92
96
return redirect(" /" )
93
97
```
98
+
94
99
## Step 7: Implement Federated Token Route
95
100
Add a new route for handling federated connections:
96
101
``` python
@@ -157,6 +162,7 @@ def call_third_party_api(access_token):
157
162
``` bash
158
163
python server.py
159
164
```
165
+
160
166
## Key Concepts
161
167
1 . ** Federated Connection** : An Auth0 feature that allows your application to obtain access tokens for third-party services through Auth0.
162
168
2 . ** Token Exchange** : The process of exchanging a refresh token for a service-specific access token.
0 commit comments