kinde-python-sdk 2.0.0b2__py3-none-any.whl → 2.0.0b3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kinde-python-sdk
3
- Version: 2.0.0b2
3
+ Version: 2.0.0b3
4
4
  Summary: Connect your app to the Kinde platform
5
5
  Author-email: Kinde Engineering <engineering@kinde.com>
6
6
  Project-URL: Homepage, https://github.com/kinde-oss/kinde-python-sdk
@@ -166,6 +166,169 @@ data = storage_manager.get("some_key")
166
166
  # After initializing both OAuth and KindeApiClient use the following fn to get proper urls
167
167
  api_client.fetch_openid_configuration(oauth)
168
168
 
169
+ ## Framework Integrations
170
+
171
+ The Kinde Python SDK provides seamless integration with popular Python web frameworks. Below are detailed guides for using Kinde with FastAPI and Flask.
172
+
173
+ ### FastAPI Integration
174
+
175
+ The `kinde_fastapi` module provides easy integration with FastAPI applications.
176
+
177
+ #### Installation
178
+
179
+ ```bash
180
+ pip install fastapi uvicorn python-multipart
181
+ ```
182
+
183
+ #### Basic Setup
184
+
185
+ ```python
186
+ from fastapi import FastAPI
187
+ from kinde_sdk.auth.oauth import OAuth
188
+
189
+ # Initialize FastAPI app
190
+ app = FastAPI()
191
+
192
+ # Initialize Kinde OAuth with FastAPI framework
193
+ kinde_oauth = OAuth(
194
+ framework="fastapi",
195
+ app=app
196
+ )
197
+
198
+ # Example home route
199
+ @app.get("/")
200
+ async def home(request: Request):
201
+ if kinde_oauth.is_authenticated():
202
+ user = kinde_oauth.get_user_info()
203
+ return f"Welcome, {user.get('email', 'User')}!"
204
+ return "Please log in"
205
+ ```
206
+
207
+ #### Configuration
208
+
209
+ Create a `.env` file with your Kinde credentials:
210
+
211
+ ```env
212
+ KINDE_CLIENT_ID=your_client_id
213
+ KINDE_CLIENT_SECRET=your_client_secret
214
+ KINDE_REDIRECT_URI=http://localhost:8000/callback
215
+ KINDE_DOMAIN=your_kinde_domain
216
+ ```
217
+
218
+ #### Available Routes
219
+
220
+ The FastAPI integration automatically provides these routes:
221
+
222
+ - `/login` - Redirects to Kinde login
223
+ - `/callback` - Handles OAuth callback
224
+ - `/logout` - Logs out the user
225
+ - `/register` - Redirects to Kinde registration
226
+ - `/user` - Returns user information
227
+
228
+ #### Protected Routes
229
+
230
+ ```python
231
+ from fastapi import Depends
232
+ from kinde_sdk.kinde_api_client import KindeApiClient
233
+
234
+ @router.get("/protected")
235
+ async def protected_route(
236
+ kinde_client: KindeApiClient = Depends(get_kinde_client)
237
+ ):
238
+ return {"message": "This is a protected route"}
239
+ ```
240
+
241
+ ### Flask Integration
242
+
243
+ The `kinde_flask` module provides easy integration with Flask applications.
244
+
245
+ #### Installation
246
+
247
+ ```bash
248
+ pip install flask python-dotenv flask-session
249
+ ```
250
+
251
+ #### Basic Setup
252
+
253
+ ```python
254
+ from flask import Flask
255
+ from kinde_sdk.auth.oauth import OAuth
256
+
257
+ # Initialize Flask app
258
+ app = Flask(__name__)
259
+
260
+ # Configure Flask session
261
+ app.config['SECRET_KEY'] = 'your-secret-key'
262
+ app.config['SESSION_TYPE'] = 'filesystem'
263
+ app.config['SESSION_PERMANENT'] = False
264
+
265
+ # Initialize Kinde OAuth with Flask framework
266
+ kinde_oauth = OAuth(
267
+ framework="flask",
268
+ app=app
269
+ )
270
+
271
+ # Example home route
272
+ @app.route('/')
273
+ def home():
274
+ if kinde_oauth.is_authenticated():
275
+ user = kinde_oauth.get_user_info()
276
+ return f"Welcome, {user.get('email', 'User')}!"
277
+ return "Please log in"
278
+ ```
279
+
280
+ #### Configuration
281
+
282
+ Create a `.env` file with your Kinde credentials:
283
+
284
+ ```env
285
+ KINDE_CLIENT_ID=your_client_id
286
+ KINDE_CLIENT_SECRET=your_client_secret
287
+ KINDE_REDIRECT_URI=http://localhost:5000/callback
288
+ KINDE_DOMAIN=your_kinde_domain
289
+ ```
290
+
291
+ #### Available Routes
292
+
293
+ The Flask integration automatically provides these routes:
294
+
295
+ - `/login` - Redirects to Kinde login
296
+ - `/callback` - Handles OAuth callback
297
+ - `/logout` - Logs out the user
298
+ - `/register` - Redirects to Kinde registration
299
+ - `/user` - Returns user information
300
+
301
+ #### Protected Routes
302
+
303
+ ```python
304
+ from functools import wraps
305
+ from flask import session, redirect
306
+
307
+ def login_required(f):
308
+ @wraps(f)
309
+ def decorated_function(*args, **kwargs):
310
+ if not kinde_oauth.is_authenticated():
311
+ return redirect('/login')
312
+ return f(*args, **kwargs)
313
+ return decorated_function
314
+
315
+ @app.route('/protected')
316
+ @login_required
317
+ def protected_route():
318
+ return {"message": "This is a protected route"}
319
+ ```
320
+
321
+ #### Security Considerations
322
+
323
+ For both FastAPI and Flask integrations:
324
+
325
+ 1. Always use HTTPS in production
326
+ 2. Use a secure session secret key
327
+ 3. Implement proper state parameter validation
328
+ 4. Handle OAuth errors appropriately
329
+ 5. Implement proper session management
330
+ 6. Consider implementing CSRF protection
331
+
169
332
  # Kinde Management API Module
170
333
 
171
334
  This module provides a client for the Kinde Management API, allowing you to manage users, organizations, roles, permissions, and feature flags programmatically.
@@ -542,15 +705,13 @@ def main():
542
705
  if __name__ == "__main__":
543
706
  main()
544
707
 
545
- ```
546
-
547
708
  ## Publishing
548
709
 
549
710
  The core team handles publishing.
550
711
 
551
712
  ## Contributing
552
713
 
553
- Please refer to Kindes [contributing guidelines](https://github.com/kinde-oss/.github/blob/489e2ca9c3307c2b2e098a885e22f2239116394a/CONTRIBUTING.md).
714
+ Please refer to Kinde's [contributing guidelines](https://github.com/kinde-oss/.github/blob/489e2ca9c3307c2b2e098a885e22f2239116394a/CONTRIBUTING.md).
554
715
 
555
716
  ## License
556
717
 
@@ -1,8 +1,8 @@
1
1
  kinde_fastapi/__init__.py,sha256=FzB0zDBbzaLLvGZBPrBZN94I6LRZdkT4RSmGUsbh3mA,470
2
2
  kinde_flask/__init__.py,sha256=bKBuqqY9ZTBQL9vLmtuOm2FOjGpoLqyCj3CxKrt7nho,451
3
- kinde_python_sdk-2.0.0b2.dist-info/licenses/LICENSE,sha256=iT6AIO6NJn_mo0kDD5mpz2zp9GpzH6YdhqOmkCBg-kQ,1385
3
+ kinde_python_sdk-2.0.0b3.dist-info/licenses/LICENSE,sha256=iT6AIO6NJn_mo0kDD5mpz2zp9GpzH6YdhqOmkCBg-kQ,1385
4
4
  kinde_sdk/__init__.py,sha256=ENi586ORHEtNgZlBCJmXYYXUmfH_yL3VzHzuOW52-mo,571
5
- kinde_python_sdk-2.0.0b2.dist-info/METADATA,sha256=Kz3wkIyPyEuRRsphUoeYnm6E11b7QMOeZQqLxf_9lU8,17545
6
- kinde_python_sdk-2.0.0b2.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
7
- kinde_python_sdk-2.0.0b2.dist-info/top_level.txt,sha256=TUU3EVjV6O4brF-mooQr6pnTk-jXJphmIWRHCIdyIgI,36
8
- kinde_python_sdk-2.0.0b2.dist-info/RECORD,,
5
+ kinde_python_sdk-2.0.0b3.dist-info/METADATA,sha256=qiD9HUdSV0ltXrK261nAzHHPT53uRLc4vK805rv__E8,21251
6
+ kinde_python_sdk-2.0.0b3.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
7
+ kinde_python_sdk-2.0.0b3.dist-info/top_level.txt,sha256=TUU3EVjV6O4brF-mooQr6pnTk-jXJphmIWRHCIdyIgI,36
8
+ kinde_python_sdk-2.0.0b3.dist-info/RECORD,,