@@ -16,15 +16,17 @@ cd auth0-python-web-app
1616``` bash
1717pip install -r requirements.txt
1818```
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+
2122``` python
2223from auth0.authentication import GetToken
2324# Initialize the GetToken object with your Auth0 domain and client credentials
2425auth_client = GetToken(' your-domain.us.auth0.com' , ' your-client-id' , client_secret = ' your-client-secret' )
2526```
27+
2628## 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:
2830``` python
2931@app.route (" /login" )
3032def login ():
@@ -56,6 +58,7 @@ def login():
5658 )
5759 return redirect(auth_url)
5860```
61+
5962## Step 6: Update Callback Handler
6063Update the callback handler to work with the custom login route:
6164``` python
@@ -83,6 +86,7 @@ def callback():
8386 " refresh_token" : token_response.get(" refresh_token" ),
8487 " id_token" : token_response.get(" id_token" )
8588 }
89+
8690 # Get user info
8791 user_info_url = f " https:// { env.get(' AUTH0_DOMAIN' )} /userinfo "
8892 user_info_headers = {" Authorization" : f " Bearer { token_response.get(' access_token' )} " }
@@ -91,6 +95,7 @@ def callback():
9195 session[" user" ] = user_info
9296 return redirect(" /" )
9397```
98+
9499## Step 7: Implement Federated Token Route
95100Add a new route for handling federated connections:
96101``` python
@@ -157,6 +162,7 @@ def call_third_party_api(access_token):
157162``` bash
158163python server.py
159164```
165+
160166## Key Concepts
1611671 . ** Federated Connection** : An Auth0 feature that allows your application to obtain access tokens for third-party services through Auth0.
1621682 . ** Token Exchange** : The process of exchanging a refresh token for a service-specific access token.
0 commit comments