You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/developer-tools/sdks/backend/python-sdk.mdx
+52-25Lines changed: 52 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,8 @@ The Kinde Python SDK allows developers to quickly and securely integrate a new o
19
19
20
20
If you are using a previous version of Python, you may need to refer to the [previous v1 SDK](/developer-tools/sdks/backend/python-sdk-v1/).
21
21
22
+
If you're migrating from an older version of the SDK, see our [migration guide](https://github.com/kinde-oss/kinde-python-sdk/blob/main/MIGRATION.md) for detailed instructions.
23
+
22
24
For new projects, you can find our [Starter Kit on GitHub](https://github.com/kinde-starter-kits/python-starter-kit).
23
25
24
26
## Install
@@ -49,12 +51,18 @@ The Kinde Python SDK uses environment variables for configuration. Here are all
49
51
-`SITE_PORT` - Your application's port (default: `5000`)
50
52
-`SITE_URL` - Your application's base URL
51
53
-`CODE_VERIFIER` - Required for PKCE flow (auto-generated if not provided)
For more information about how organizations work in Kinde, see [Kinde organizations for developers](/build/organizations/orgs-for-developers/).
628
622
629
-
### Token storage
623
+
### Token and session management
624
+
625
+
The Kinde Python SDK automatically handles token and session management for your application. Once a user has successfully authenticated, the SDK manages:
626
+
627
+
-**Token acquisition and storage**: Automatically obtains and securely stores access tokens, ID tokens, and refresh tokens
628
+
-**Token refresh**: Automatically refreshes tokens when they expire
629
+
-**Session management**: Handles user sessions across requests
630
+
-**Framework integration**: Works seamlessly with Flask and FastAPI session systems
631
+
632
+
The SDK uses the session configuration from your environment variables (`SECRET_KEY`, `SESSION_TYPE`, `SESSION_PERMANENT`) to manage sessions appropriately for your chosen framework.
630
633
631
-
Once the user has successfully authenticated, you'll get a JWT and possibly a refresh token that should be stored securely.
634
+
#### Token types
635
+
636
+
The SDK supports two types of tokens:
637
+
638
+
1.**Access Token** (`token_type="access_token"`):
639
+
- Contains authorization information
640
+
- Used for API access
641
+
- Contains permissions and organization context
642
+
- Default token type
643
+
644
+
2.**ID Token** (`token_type="id_token"`):
645
+
- Contains user identity information
646
+
- Used for user profile data
647
+
- Contains name, email, and other user details
648
+
- Must be explicitly requested using `token_type="id_token"`
649
+
650
+
#### Session handling
651
+
652
+
The SDK automatically integrates with your framework's session system:
-**FastAPI**: Integrates with FastAPI's session handling
656
+
657
+
You don't need to manually manage tokens or sessions - the SDK handles this automatically for you.
632
658
633
659
## Management API
634
660
@@ -716,13 +742,14 @@ except Exception as e:
716
742
717
743
### Token management
718
744
719
-
The Management API client automatically handles token management, including:
720
-
- Token acquisition
721
-
- Token refresh
722
-
- Token storage
723
-
- Thread safety
745
+
The Management API client has its own token management system for API authentication, which is separate from the core SDK's user session token management. The Management API client automatically handles:
746
+
747
+
-**accessing Kinde Management API endpoints**: Obtains tokens for accessing Kinde's management endpoints
748
+
-**Token refresh**: Automatically refreshes management API tokens when they expire
749
+
-**Token storage**: Securely stores management API tokens
750
+
-**Thread safety**: Ensures thread-safe token handling for concurrent requests
724
751
725
-
You don't need to manage tokens manually - the client handles this for you.
752
+
You don't need to manually manage Management API tokens - the client handles this for you. This is different from the core SDK's user session token management, which handles user authentication tokens automatically.
0 commit comments