kinde-python-sdk 2.0.7__py3-none-any.whl → 2.0.8__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.7
3
+ Version: 2.0.8
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
@@ -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.7.dist-info/licenses/LICENSE,sha256=iT6AIO6NJn_mo0kDD5mpz2zp9GpzH6YdhqOmkCBg-kQ,1385
16
+ kinde_python_sdk-2.0.8.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
@@ -109,7 +109,7 @@ kinde_sdk/apis/tags/users_api.py,sha256=06qeWo8ZNNZvKQ5hl0ImtPvNSbzDKkceZj7ACrlu
109
109
  kinde_sdk/apis/tags/webhooks_api.py,sha256=AmLDLeW6aLz3lnqUGGd2dpVxuVKxW1KgIW2rdtUNJmw,925
110
110
  kinde_sdk/auth/__init__.py,sha256=czQs-NJ3R22EXkcnszl3YJKmjsB-mVpJ4T11zbRb_4Y,379
111
111
  kinde_sdk/auth/base_auth.py,sha256=hV-xjaGa35YMDFpmEWQgTNM7w6ZHskLm_p5cnXSSLJY,1253
112
- kinde_sdk/auth/claims.py,sha256=g0vlQtHBNyuELCNSTuahr3ZhBma4Htp2KjKCtKq1f90,1540
112
+ kinde_sdk/auth/claims.py,sha256=sS4cvtEYQyTlT4WacibyKzp-5eTTH4JbMnDabMTX31w,1560
113
113
  kinde_sdk/auth/config_loader.py,sha256=L01kqmzUMKQ0X_PA9MYcWSeJiVoDfrB4RANQGWS76UA,879
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
@@ -117,7 +117,7 @@ kinde_sdk/auth/login_options.py,sha256=3Fvbo-rjLzbV14Np48Ogw0HieThjlRtfP4VHztJtG
117
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
- kinde_sdk/auth/token_manager.py,sha256=uG9TFcJ_K4hbgFEP9gy_S1xRUBpzD5ZYT37LzMWoWHA,7182
120
+ kinde_sdk/auth/token_manager.py,sha256=HSfyKmc4kyoQz2NeRPVWtpY4E4rtf2w6SWArRlQ7-5s,8278
121
121
  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
@@ -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.7.dist-info/METADATA,sha256=hfaFwDNTTOdeJhG8N1f_T2cwvtq9UP_5pee2R_VZXvw,23482
726
- kinde_python_sdk-2.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
727
- kinde_python_sdk-2.0.7.dist-info/top_level.txt,sha256=TUU3EVjV6O4brF-mooQr6pnTk-jXJphmIWRHCIdyIgI,36
728
- kinde_python_sdk-2.0.7.dist-info/RECORD,,
725
+ kinde_python_sdk-2.0.8.dist-info/METADATA,sha256=IpZmsHIm-6tEYfeHhPWBBWmrepU4Wez1j90Y98KKPCQ,23482
726
+ kinde_python_sdk-2.0.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
727
+ kinde_python_sdk-2.0.8.dist-info/top_level.txt,sha256=TUU3EVjV6O4brF-mooQr6pnTk-jXJphmIWRHCIdyIgI,36
728
+ kinde_python_sdk-2.0.8.dist-info/RECORD,,
kinde_sdk/auth/claims.py CHANGED
@@ -24,7 +24,7 @@ class Claims(BaseAuth):
24
24
  "value": None
25
25
  }
26
26
 
27
- claims = token_manager.get_claims()
27
+ claims = token_manager.get_claims(token_type)
28
28
  value = claims.get(claim_name)
29
29
 
30
30
  return {
@@ -46,7 +46,7 @@ class Claims(BaseAuth):
46
46
  if not token_manager:
47
47
  return {}
48
48
 
49
- return token_manager.get_claims()
49
+ return token_manager.get_claims(token_type)
50
50
 
51
51
  # Create a singleton instance
52
52
  claims = Claims()
@@ -153,17 +153,46 @@ class TokenManager:
153
153
  """Get the ID token if available."""
154
154
  return self.tokens.get("id_token")
155
155
 
156
- def get_claims(self):
157
- """Get the claims from the access token if available, falling back to ID token claims."""
158
- # First try to get claims from access token
159
- claims = self.tokens.get("access_token_claims", {})
156
+ def get_claims(self, token_type: str = "access_token"):
157
+ """Get the claims from the specified token type.
158
+
159
+ Args:
160
+ token_type (str): The type of token to get claims from.
161
+ Valid values are "access_token" or "id_token".
162
+
163
+ Returns:
164
+ dict: The claims from the specified token, or empty dict if not available.
165
+ """
166
+ # Validate token type
167
+ valid_token_types = ["access_token", "id_token"]
168
+ if token_type not in valid_token_types:
169
+ logging.warning(f"Invalid token_type '{token_type}'. Valid types are: {valid_token_types}")
170
+ return {}
171
+
172
+ # Use f-string for safer string formatting
173
+ claims_key = f"{token_type}_claims"
174
+ claims = self.tokens.get(claims_key, {})
175
+
160
176
  if not claims:
161
- # Fall back to ID token claims if access token claims are not available
162
- claims = self.tokens.get("id_token_claims", {})
163
- if not claims:
164
- logging.warning("No claims available in token manager")
177
+ logging.warning(f"No claims available for token type: {token_type}")
178
+
165
179
  return claims
166
180
 
181
+ def get_claim(self, key: str, token_type: str = "access_token"):
182
+ """Get a specific claim from the specified token type.
183
+
184
+ Args:
185
+ key (str): The claim key to retrieve
186
+ token_type (str): The type of token to get the claim from.
187
+ Valid values are "access_token" or "id_token".
188
+
189
+ Returns:
190
+ dict: Dictionary containing the claim name and value, or empty dict if not found.
191
+ """
192
+ claims = self.get_claims(token_type)
193
+ value = claims.get(key)
194
+ return {"name": key, "value": value}
195
+
167
196
  def revoke_token(self):
168
197
  """ Revoke the current access token. """
169
198
  if "access_token" not in self.tokens: