kinde-python-sdk 2.0.1__py3-none-any.whl → 2.0.3__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.
- kinde_fastapi/examples/example_app.py +1 -1
- {kinde_python_sdk-2.0.1.dist-info → kinde_python_sdk-2.0.3.dist-info}/METADATA +1 -1
- {kinde_python_sdk-2.0.1.dist-info → kinde_python_sdk-2.0.3.dist-info}/RECORD +8 -8
- kinde_sdk/auth/oauth.py +10 -7
- kinde_sdk/core/helpers.py +37 -1
- {kinde_python_sdk-2.0.1.dist-info → kinde_python_sdk-2.0.3.dist-info}/WHEEL +0 -0
- {kinde_python_sdk-2.0.1.dist-info → kinde_python_sdk-2.0.3.dist-info}/licenses/LICENSE +0 -0
- {kinde_python_sdk-2.0.1.dist-info → kinde_python_sdk-2.0.3.dist-info}/top_level.txt +0 -0
|
@@ -41,7 +41,7 @@ async def home(request: Request):
|
|
|
41
41
|
return f"""
|
|
42
42
|
<html>
|
|
43
43
|
<body>
|
|
44
|
-
<h1>Welcome, {user.get('email'
|
|
44
|
+
<h1>Welcome, {user.get('email')}!</h1>
|
|
45
45
|
<p>claims: {await claims.get_all_claims()}</p>
|
|
46
46
|
<p>feature flags: {await feature_flags.get_all_flags()}</p>
|
|
47
47
|
<p>permissions: {await permissions.get_permissions()}</p>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
kinde_fastapi/__init__.py,sha256=FzB0zDBbzaLLvGZBPrBZN94I6LRZdkT4RSmGUsbh3mA,470
|
|
2
|
-
kinde_fastapi/examples/example_app.py,sha256=
|
|
2
|
+
kinde_fastapi/examples/example_app.py,sha256=FmqAhAxkLLEFxNBsRx1eVhGADRskXCZtHc76WwoDsS4,1919
|
|
3
3
|
kinde_fastapi/examples/session.py,sha256=WblGM7TM2JCKdSFsd2OmSP0daexZ7E6ZS1xgTQY_etY,2472
|
|
4
4
|
kinde_fastapi/framework/__init__.py,sha256=tpTI84q7HCHMlREslMrngIlKwC8CDog9bEMI_ydhCUs,181
|
|
5
5
|
kinde_fastapi/framework/fastapi_framework.py,sha256=-MiBFddfY3NiB9BE_b8BBYAxfGbhOQKO-RXUsCu4a3U,6767
|
|
@@ -13,7 +13,7 @@ kinde_flask/framework/flask_framework.py,sha256=I4dVWmkyd0FBqjAkOyftebm7_qpI9uxk
|
|
|
13
13
|
kinde_flask/framework/flask_framework_factory.py,sha256=ALpsj-cHBox3ktRxi-CyZ5Q6EOvacfdu4pvlTYkuviA,802
|
|
14
14
|
kinde_flask/middleware/framework_middleware.py,sha256=XFK6kgMDuHkrawDJ0_MMgLO7es0YQVjlVDDRDgwlCJ0,1012
|
|
15
15
|
kinde_flask/storage/flask_storage_factory.py,sha256=MitOUbfCbfvSQFFoUbbnbXLEOL_qajS29Mlsn0TyTsY,2562
|
|
16
|
-
kinde_python_sdk-2.0.
|
|
16
|
+
kinde_python_sdk-2.0.3.dist-info/licenses/LICENSE,sha256=iT6AIO6NJn_mo0kDD5mpz2zp9GpzH6YdhqOmkCBg-kQ,1385
|
|
17
17
|
kinde_sdk/__init__.py,sha256=Mh3eVcnJDk-KdQfxVUsF19NgBYexoJCwG5iAbD1LEdQ,1052
|
|
18
18
|
kinde_sdk/api_client.py,sha256=GEb1BIjvIrUe8mFIr7hppp2PO604BiSlAr0_TYBfuy4,58496
|
|
19
19
|
kinde_sdk/configuration.py,sha256=oqZGvKEf4kNNURbI1pip2ZVVcDyRTSmmnjXWziH4s80,15765
|
|
@@ -114,7 +114,7 @@ kinde_sdk/auth/config_loader.py,sha256=L01kqmzUMKQ0X_PA9MYcWSeJiVoDfrB4RANQGWS76
|
|
|
114
114
|
kinde_sdk/auth/enums.py,sha256=Xbk7jwXtq_TViZSfBy6h9lon8VEA5v6ssUl-3yKp8Zk,538
|
|
115
115
|
kinde_sdk/auth/feature_flags.py,sha256=VSqfyqNmYLo3Q74nyo4L8W8jt8msZ_v-45Y7pW_48VA,3810
|
|
116
116
|
kinde_sdk/auth/login_options.py,sha256=3Fvbo-rjLzbV14Np48Ogw0HieThjlRtfP4VHztJtGCs,914
|
|
117
|
-
kinde_sdk/auth/oauth.py,sha256=
|
|
117
|
+
kinde_sdk/auth/oauth.py,sha256=bXWM6Mo7H8EgrD2GSOfhibvwz6MVMPe7-wM1PaL6_6o,26136
|
|
118
118
|
kinde_sdk/auth/permissions.py,sha256=A9BmGt3OokuvS-4twveCZdCPFY-QobyzqlgGVo8eSoI,1913
|
|
119
119
|
kinde_sdk/auth/portals.py,sha256=Z3goLvio-Xw7VjTRrQZXKOFkTMvtF78nKzFF5-u4rkY,4530
|
|
120
120
|
kinde_sdk/auth/token_manager.py,sha256=uG9TFcJ_K4hbgFEP9gy_S1xRUBpzD5ZYT37LzMWoWHA,7182
|
|
@@ -122,7 +122,7 @@ kinde_sdk/auth/tokens.py,sha256=eZKJTTw764FrzvxurWNee1_ZX1Q2FQjJUXBlsMlp2A0,2367
|
|
|
122
122
|
kinde_sdk/auth/user_session.py,sha256=CmFotC9ONzHwPMRJy4SOT7tOI_63dHv_ttpdNHssH8Y,7657
|
|
123
123
|
kinde_sdk/core/__init__.py,sha256=ejO0P_oXuiO5V-MJVRqKu6y0fAWKyi4iL2UIRGXhLy0,358
|
|
124
124
|
kinde_sdk/core/exceptions.py,sha256=Xc_kTcGa5equDBxbJ0Vl4jzHj0LB5cThLLprFnB1q1c,771
|
|
125
|
-
kinde_sdk/core/helpers.py,sha256=
|
|
125
|
+
kinde_sdk/core/helpers.py,sha256=ebwxPzzTpJJLwleDM0cR3VFsXw88eoRTx4L_aYonOK4,23508
|
|
126
126
|
kinde_sdk/core/framework/__init__.py,sha256=eGDHV-UtJWOh7LYqKZpihR6hApfZnaJEUGe8BlUXg28,228
|
|
127
127
|
kinde_sdk/core/framework/framework_context.py,sha256=JxB168zlSEMmtrUL1e6G8kK-aUR8AqT4xpzNNEdQmuk,1164
|
|
128
128
|
kinde_sdk/core/framework/framework_factory.py,sha256=wOznkAeo5dlwpRobxP80oHTA3YB-8qEiYYvCxaG5q6o,4489
|
|
@@ -722,7 +722,7 @@ kinde_sdk/test/test_models/test_user_profile_v2.py,sha256=QzYjvjtTGa1ktE5ruyGBm_
|
|
|
722
722
|
kinde_sdk/test/test_models/test_users.py,sha256=wJQR5K7dsfHQQsOQp4mrHWQynFPHwL-gDtbgVifNfMs,537
|
|
723
723
|
kinde_sdk/test/test_models/test_users_response.py,sha256=BCcKxe9GctDrOXOzw0Q7O1ijKy_93Oj3E2wHW00y624,869
|
|
724
724
|
kinde_sdk/test/test_models/test_webhook.py,sha256=KNfR8sKAK5H2vX_cXYGT5EfgaVP7_egC39uY6-s-4qo,544
|
|
725
|
-
kinde_python_sdk-2.0.
|
|
726
|
-
kinde_python_sdk-2.0.
|
|
727
|
-
kinde_python_sdk-2.0.
|
|
728
|
-
kinde_python_sdk-2.0.
|
|
725
|
+
kinde_python_sdk-2.0.3.dist-info/METADATA,sha256=gwjJd8utSYgEl4tBnIdbyBMqhBrN0ZzDVFy34TuFquw,23482
|
|
726
|
+
kinde_python_sdk-2.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
727
|
+
kinde_python_sdk-2.0.3.dist-info/top_level.txt,sha256=TUU3EVjV6O4brF-mooQr6pnTk-jXJphmIWRHCIdyIgI,36
|
|
728
|
+
kinde_python_sdk-2.0.3.dist-info/RECORD,,
|
kinde_sdk/auth/oauth.py
CHANGED
|
@@ -2,6 +2,7 @@ import os
|
|
|
2
2
|
import requests
|
|
3
3
|
import logging
|
|
4
4
|
import time
|
|
5
|
+
import asyncio
|
|
5
6
|
from typing import Any, Dict, List, Optional, Tuple, Union
|
|
6
7
|
from urllib.parse import urlencode, urlparse, quote
|
|
7
8
|
|
|
@@ -12,7 +13,7 @@ from kinde_sdk.core.framework.framework_factory import FrameworkFactory
|
|
|
12
13
|
from .config_loader import load_config
|
|
13
14
|
from .enums import GrantType, IssuerRouteTypes, PromptTypes
|
|
14
15
|
from .login_options import LoginOptions
|
|
15
|
-
from kinde_sdk.core.helpers import generate_random_string, base64_url_encode, generate_pkce_pair, get_user_details as helper_get_user_details
|
|
16
|
+
from kinde_sdk.core.helpers import generate_random_string, base64_url_encode, generate_pkce_pair, get_user_details as helper_get_user_details, get_user_details_sync
|
|
16
17
|
from kinde_sdk.core.exceptions import (
|
|
17
18
|
KindeConfigurationException,
|
|
18
19
|
KindeLoginException,
|
|
@@ -167,14 +168,16 @@ class OAuth:
|
|
|
167
168
|
token_manager = self._session_manager.get_token_manager(user_id)
|
|
168
169
|
if not token_manager:
|
|
169
170
|
raise KindeConfigurationException("No token manager found for user")
|
|
171
|
+
|
|
172
|
+
user_details = get_user_details_sync(
|
|
173
|
+
userinfo_url=self.userinfo_url,
|
|
174
|
+
token_manager=token_manager,
|
|
175
|
+
logger=self._logger
|
|
176
|
+
)
|
|
170
177
|
|
|
171
178
|
# Get claims from token manager
|
|
172
|
-
self._logger.
|
|
173
|
-
|
|
174
|
-
if not claims:
|
|
175
|
-
raise KindeConfigurationException("No user claims found")
|
|
176
|
-
self._logger.debug(f"Return the claims")
|
|
177
|
-
return claims
|
|
179
|
+
self._logger.info(f"Get the claims from the token manager {user_details}")
|
|
180
|
+
return user_details
|
|
178
181
|
|
|
179
182
|
def _set_api_endpoints(self):
|
|
180
183
|
"""Set API endpoints based on the host URL."""
|
kinde_sdk/core/helpers.py
CHANGED
|
@@ -6,6 +6,7 @@ import requests
|
|
|
6
6
|
import json
|
|
7
7
|
import re
|
|
8
8
|
import time
|
|
9
|
+
import asyncio
|
|
9
10
|
from typing import Dict, Union, Any, Optional, List
|
|
10
11
|
|
|
11
12
|
logger = logging.getLogger("kinde_sdk")
|
|
@@ -692,4 +693,39 @@ def sanitize_url(url: str) -> str:
|
|
|
692
693
|
Sanitized URL
|
|
693
694
|
"""
|
|
694
695
|
# Basic URL sanitization
|
|
695
|
-
return url.strip()
|
|
696
|
+
return url.strip()
|
|
697
|
+
|
|
698
|
+
def get_user_details_sync(userinfo_url: str, token_manager, logger) -> Dict[str, Any]:
|
|
699
|
+
"""
|
|
700
|
+
Retrieve user information synchronously, handling both sync and async contexts.
|
|
701
|
+
|
|
702
|
+
This function works in both Flask (no event loop) and FastAPI (has event loop) environments.
|
|
703
|
+
|
|
704
|
+
Args:
|
|
705
|
+
userinfo_url: URL for user information endpoint
|
|
706
|
+
token_manager: Token manager instance
|
|
707
|
+
logger: Logger instance
|
|
708
|
+
|
|
709
|
+
Returns:
|
|
710
|
+
Dictionary with user profile information
|
|
711
|
+
|
|
712
|
+
Raises:
|
|
713
|
+
ValueError: If token is not available or is invalid
|
|
714
|
+
requests.RequestException: If the API request fails
|
|
715
|
+
"""
|
|
716
|
+
try:
|
|
717
|
+
# Check if we're in an event loop
|
|
718
|
+
asyncio.get_running_loop()
|
|
719
|
+
# We're in an event loop (FastAPI), so we can't use asyncio.run()
|
|
720
|
+
# Instead, we'll make a synchronous request directly
|
|
721
|
+
access_token = token_manager.get_access_token()
|
|
722
|
+
headers = {
|
|
723
|
+
"Authorization": f"Bearer {access_token}",
|
|
724
|
+
"Accept": "application/json"
|
|
725
|
+
}
|
|
726
|
+
response = requests.get(userinfo_url, headers=headers)
|
|
727
|
+
response.raise_for_status()
|
|
728
|
+
return response.json()
|
|
729
|
+
except RuntimeError:
|
|
730
|
+
# No event loop running (Flask), use asyncio.run
|
|
731
|
+
return asyncio.run(get_user_details(userinfo_url, token_manager, logger))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|