Skip to content

Commit 4076721

Browse files
Merge pull request #479 from brettchaldecott/docs/update-python-sdk-documentation
docs: update Python SDK documentation (1 of 2)
2 parents 13d2206 + 7b507a3 commit 4076721

File tree

1 file changed

+52
-25
lines changed

1 file changed

+52
-25
lines changed

src/content/docs/developer-tools/sdks/backend/python-sdk.mdx

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ The Kinde Python SDK allows developers to quickly and securely integrate a new o
1919

2020
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/).
2121

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+
2224
For new projects, you can find our [Starter Kit on GitHub](https://github.com/kinde-starter-kits/python-starter-kit).
2325

2426
## Install
@@ -49,12 +51,18 @@ The Kinde Python SDK uses environment variables for configuration. Here are all
4951
- `SITE_PORT` - Your application's port (default: `5000`)
5052
- `SITE_URL` - Your application's base URL
5153
- `CODE_VERIFIER` - Required for PKCE flow (auto-generated if not provided)
52-
- `SECRET_KEY` - Used for session management
54+
55+
**Session management variables** (core SDK features):
56+
- `SECRET_KEY` - Used for session management and token security
5357
- `SESSION_TYPE` - Session storage type (e.g., `filesystem`)
5458
- `SESSION_PERMANENT` - Whether sessions are permanent (default: `False`)
59+
60+
**Application configuration**:
5561
- `TEMPLATES_AUTO_RELOAD` - Whether to auto-reload templates (default: `True`)
56-
- `MGMT_API_CLIENT_ID` - Management API client ID (if using management features)
57-
- `MGMT_API_CLIENT_SECRET` - Management API client secret (if using management features)
62+
63+
**Management API variables** (only needed if using Management API features):
64+
- `MGMT_API_CLIENT_ID` - Management API client ID
65+
- `MGMT_API_CLIENT_SECRET` - Management API client secret
5866

5967
Example `.env` file:
6068
```bash
@@ -540,21 +548,7 @@ Here are some common claims you might want to access:
540548
"org_id"
541549
```
542550

543-
### Token types
544-
545-
The SDK supports two types of tokens:
546-
547-
1. Access Token (`token_type="access_token"`):
548-
- Contains authorization information
549-
- Used for API access
550-
- Contains permissions and organization context
551-
- Default token type
552551

553-
2. ID Token (`token_type="id_token"`):
554-
- Contains user identity information
555-
- Used for user profile data
556-
- Contains name, email, and other user details
557-
- Must be explicitly requested using `token_type="id_token"`
558552

559553
## Organizations
560554

@@ -626,9 +620,41 @@ oauth.get_user_organizations()
626620

627621
For more information about how organizations work in Kinde, see [Kinde organizations for developers](/build/organizations/orgs-for-developers/).
628622

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.
630633

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:
653+
654+
- **Flask**: Uses Flask's built-in session management
655+
- **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.
632658

633659
## Management API
634660

@@ -716,13 +742,14 @@ except Exception as e:
716742

717743
### Token management
718744

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
724751

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.
726753

727754
### Best practices
728755

0 commit comments

Comments
 (0)