kinde-python-sdk 2.0.0b2__tar.gz → 2.0.0b3__tar.gz

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
 
@@ -125,6 +125,169 @@ data = storage_manager.get("some_key")
125
125
  # After initializing both OAuth and KindeApiClient use the following fn to get proper urls
126
126
  api_client.fetch_openid_configuration(oauth)
127
127
 
128
+ ## Framework Integrations
129
+
130
+ The Kinde Python SDK provides seamless integration with popular Python web frameworks. Below are detailed guides for using Kinde with FastAPI and Flask.
131
+
132
+ ### FastAPI Integration
133
+
134
+ The `kinde_fastapi` module provides easy integration with FastAPI applications.
135
+
136
+ #### Installation
137
+
138
+ ```bash
139
+ pip install fastapi uvicorn python-multipart
140
+ ```
141
+
142
+ #### Basic Setup
143
+
144
+ ```python
145
+ from fastapi import FastAPI
146
+ from kinde_sdk.auth.oauth import OAuth
147
+
148
+ # Initialize FastAPI app
149
+ app = FastAPI()
150
+
151
+ # Initialize Kinde OAuth with FastAPI framework
152
+ kinde_oauth = OAuth(
153
+ framework="fastapi",
154
+ app=app
155
+ )
156
+
157
+ # Example home route
158
+ @app.get("/")
159
+ async def home(request: Request):
160
+ if kinde_oauth.is_authenticated():
161
+ user = kinde_oauth.get_user_info()
162
+ return f"Welcome, {user.get('email', 'User')}!"
163
+ return "Please log in"
164
+ ```
165
+
166
+ #### Configuration
167
+
168
+ Create a `.env` file with your Kinde credentials:
169
+
170
+ ```env
171
+ KINDE_CLIENT_ID=your_client_id
172
+ KINDE_CLIENT_SECRET=your_client_secret
173
+ KINDE_REDIRECT_URI=http://localhost:8000/callback
174
+ KINDE_DOMAIN=your_kinde_domain
175
+ ```
176
+
177
+ #### Available Routes
178
+
179
+ The FastAPI integration automatically provides these routes:
180
+
181
+ - `/login` - Redirects to Kinde login
182
+ - `/callback` - Handles OAuth callback
183
+ - `/logout` - Logs out the user
184
+ - `/register` - Redirects to Kinde registration
185
+ - `/user` - Returns user information
186
+
187
+ #### Protected Routes
188
+
189
+ ```python
190
+ from fastapi import Depends
191
+ from kinde_sdk.kinde_api_client import KindeApiClient
192
+
193
+ @router.get("/protected")
194
+ async def protected_route(
195
+ kinde_client: KindeApiClient = Depends(get_kinde_client)
196
+ ):
197
+ return {"message": "This is a protected route"}
198
+ ```
199
+
200
+ ### Flask Integration
201
+
202
+ The `kinde_flask` module provides easy integration with Flask applications.
203
+
204
+ #### Installation
205
+
206
+ ```bash
207
+ pip install flask python-dotenv flask-session
208
+ ```
209
+
210
+ #### Basic Setup
211
+
212
+ ```python
213
+ from flask import Flask
214
+ from kinde_sdk.auth.oauth import OAuth
215
+
216
+ # Initialize Flask app
217
+ app = Flask(__name__)
218
+
219
+ # Configure Flask session
220
+ app.config['SECRET_KEY'] = 'your-secret-key'
221
+ app.config['SESSION_TYPE'] = 'filesystem'
222
+ app.config['SESSION_PERMANENT'] = False
223
+
224
+ # Initialize Kinde OAuth with Flask framework
225
+ kinde_oauth = OAuth(
226
+ framework="flask",
227
+ app=app
228
+ )
229
+
230
+ # Example home route
231
+ @app.route('/')
232
+ def home():
233
+ if kinde_oauth.is_authenticated():
234
+ user = kinde_oauth.get_user_info()
235
+ return f"Welcome, {user.get('email', 'User')}!"
236
+ return "Please log in"
237
+ ```
238
+
239
+ #### Configuration
240
+
241
+ Create a `.env` file with your Kinde credentials:
242
+
243
+ ```env
244
+ KINDE_CLIENT_ID=your_client_id
245
+ KINDE_CLIENT_SECRET=your_client_secret
246
+ KINDE_REDIRECT_URI=http://localhost:5000/callback
247
+ KINDE_DOMAIN=your_kinde_domain
248
+ ```
249
+
250
+ #### Available Routes
251
+
252
+ The Flask integration automatically provides these routes:
253
+
254
+ - `/login` - Redirects to Kinde login
255
+ - `/callback` - Handles OAuth callback
256
+ - `/logout` - Logs out the user
257
+ - `/register` - Redirects to Kinde registration
258
+ - `/user` - Returns user information
259
+
260
+ #### Protected Routes
261
+
262
+ ```python
263
+ from functools import wraps
264
+ from flask import session, redirect
265
+
266
+ def login_required(f):
267
+ @wraps(f)
268
+ def decorated_function(*args, **kwargs):
269
+ if not kinde_oauth.is_authenticated():
270
+ return redirect('/login')
271
+ return f(*args, **kwargs)
272
+ return decorated_function
273
+
274
+ @app.route('/protected')
275
+ @login_required
276
+ def protected_route():
277
+ return {"message": "This is a protected route"}
278
+ ```
279
+
280
+ #### Security Considerations
281
+
282
+ For both FastAPI and Flask integrations:
283
+
284
+ 1. Always use HTTPS in production
285
+ 2. Use a secure session secret key
286
+ 3. Implement proper state parameter validation
287
+ 4. Handle OAuth errors appropriately
288
+ 5. Implement proper session management
289
+ 6. Consider implementing CSRF protection
290
+
128
291
  # Kinde Management API Module
129
292
 
130
293
  This module provides a client for the Kinde Management API, allowing you to manage users, organizations, roles, permissions, and feature flags programmatically.
@@ -501,15 +664,13 @@ def main():
501
664
  if __name__ == "__main__":
502
665
  main()
503
666
 
504
- ```
505
-
506
667
  ## Publishing
507
668
 
508
669
  The core team handles publishing.
509
670
 
510
671
  ## Contributing
511
672
 
512
- Please refer to Kindes [contributing guidelines](https://github.com/kinde-oss/.github/blob/489e2ca9c3307c2b2e098a885e22f2239116394a/CONTRIBUTING.md).
673
+ Please refer to Kinde's [contributing guidelines](https://github.com/kinde-oss/.github/blob/489e2ca9c3307c2b2e098a885e22f2239116394a/CONTRIBUTING.md).
513
674
 
514
675
  ## License
515
676
 
@@ -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,6 +1,6 @@
1
1
  [project]
2
2
  name = "kinde-python-sdk"
3
- version = "2.0.0-beta.2"
3
+ version = "2.0.0-beta.3"
4
4
  authors = [
5
5
  { name = "Kinde Engineering", email = "engineering@kinde.com" },
6
6
  ]