Skip to content

Commit dd767b3

Browse files
committed
merge + versioing
2 parents 950ba66 + 8e6dc1e commit dd767b3

File tree

17 files changed

+341
-30
lines changed

17 files changed

+341
-30
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [unreleased]
1010

11-
## [0.14.2] - 2023-05-24
11+
12+
## [0.14.3] - 2023-06-7
1213

1314
### Changes
1415

1516
- Update email templates to fix an issue with styling on some email clients
1617

18+
## [0.14.2] - 2023-05-29
19+
20+
- Adds additional debug logs whenever the SDK throws a `TRY_REFRESH_TOKEN` or `UNAUTHORISED` error to make debugging easier
21+
22+
1723
## [0.14.1] - 2023-05-23
1824

1925
### Changes

html/supertokens_python/constants.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h1 class="title">Module <code>supertokens_python.constants</code></h1>
4242
from __future__ import annotations
4343

4444
SUPPORTED_CDI_VERSIONS = [&#34;2.21&#34;]
45-
VERSION = &#34;0.14.1&#34;
45+
VERSION = &#34;0.14.2&#34;
4646
TELEMETRY = &#34;/telemetry&#34;
4747
USER_COUNT = &#34;/users/count&#34;
4848
USER_DELETE = &#34;/user/remove&#34;

html/supertokens_python/querier.html

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ <h1 class="title">Module <code>supertokens_python.querier</code></h1>
7070
__init_called = False
7171
__hosts: List[Host] = []
7272
__api_key: Union[None, str] = None
73-
__api_version = None
73+
api_version = None
7474
__last_tried_index: int = 0
7575
__hosts_alive_for_testing: Set[str] = set()
7676

@@ -97,8 +97,8 @@ <h1 class="title">Module <code>supertokens_python.querier</code></h1>
9797
return Querier.__hosts_alive_for_testing
9898

9999
async def get_api_version(self):
100-
if Querier.__api_version is not None:
101-
return Querier.__api_version
100+
if Querier.api_version is not None:
101+
return Querier.api_version
102102

103103
ProcessState.get_instance().add_state(
104104
AllowedProcessStates.CALLING_SERVICE_IN_GET_API_VERSION
@@ -124,8 +124,8 @@ <h1 class="title">Module <code>supertokens_python.querier</code></h1>
124124
&#34;to find the right versions&#34;
125125
)
126126

127-
Querier.__api_version = api_version
128-
return Querier.__api_version
127+
Querier.api_version = api_version
128+
return Querier.api_version
129129

130130
@staticmethod
131131
def get_instance(rid_to_core: Union[str, None] = None):
@@ -141,7 +141,7 @@ <h1 class="title">Module <code>supertokens_python.querier</code></h1>
141141
Querier.__init_called = True
142142
Querier.__hosts = hosts
143143
Querier.__api_key = api_key
144-
Querier.__api_version = None
144+
Querier.api_version = None
145145
Querier.__last_tried_index = 0
146146
Querier.__hosts_alive_for_testing = set()
147147

@@ -323,7 +323,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
323323
__init_called = False
324324
__hosts: List[Host] = []
325325
__api_key: Union[None, str] = None
326-
__api_version = None
326+
api_version = None
327327
__last_tried_index: int = 0
328328
__hosts_alive_for_testing: Set[str] = set()
329329

@@ -350,8 +350,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
350350
return Querier.__hosts_alive_for_testing
351351

352352
async def get_api_version(self):
353-
if Querier.__api_version is not None:
354-
return Querier.__api_version
353+
if Querier.api_version is not None:
354+
return Querier.api_version
355355

356356
ProcessState.get_instance().add_state(
357357
AllowedProcessStates.CALLING_SERVICE_IN_GET_API_VERSION
@@ -377,8 +377,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
377377
&#34;to find the right versions&#34;
378378
)
379379

380-
Querier.__api_version = api_version
381-
return Querier.__api_version
380+
Querier.api_version = api_version
381+
return Querier.api_version
382382

383383
@staticmethod
384384
def get_instance(rid_to_core: Union[str, None] = None):
@@ -394,7 +394,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
394394
Querier.__init_called = True
395395
Querier.__hosts = hosts
396396
Querier.__api_key = api_key
397-
Querier.__api_version = None
397+
Querier.api_version = None
398398
Querier.__last_tried_index = 0
399399
Querier.__hosts_alive_for_testing = set()
400400

@@ -552,6 +552,13 @@ <h2 class="section-title" id="header-classes">Classes</h2>
552552
except Exception as e:
553553
raise_general_exception(e)</code></pre>
554554
</details>
555+
<h3>Class variables</h3>
556+
<dl>
557+
<dt id="supertokens_python.querier.Querier.api_version"><code class="name">var <span class="ident">api_version</span></code></dt>
558+
<dd>
559+
<div class="desc"></div>
560+
</dd>
561+
</dl>
555562
<h3>Static methods</h3>
556563
<dl>
557564
<dt id="supertokens_python.querier.Querier.get_hosts_alive_for_testing"><code class="name flex">
@@ -605,7 +612,7 @@ <h3>Static methods</h3>
605612
Querier.__init_called = True
606613
Querier.__hosts = hosts
607614
Querier.__api_key = api_key
608-
Querier.__api_version = None
615+
Querier.api_version = None
609616
Querier.__last_tried_index = 0
610617
Querier.__hosts_alive_for_testing = set()</code></pre>
611618
</details>
@@ -670,8 +677,8 @@ <h3>Methods</h3>
670677
<span>Expand source code</span>
671678
</summary>
672679
<pre><code class="python">async def get_api_version(self):
673-
if Querier.__api_version is not None:
674-
return Querier.__api_version
680+
if Querier.api_version is not None:
681+
return Querier.api_version
675682

676683
ProcessState.get_instance().add_state(
677684
AllowedProcessStates.CALLING_SERVICE_IN_GET_API_VERSION
@@ -697,8 +704,8 @@ <h3>Methods</h3>
697704
&#34;to find the right versions&#34;
698705
)
699706

700-
Querier.__api_version = api_version
701-
return Querier.__api_version</code></pre>
707+
Querier.api_version = api_version
708+
return Querier.api_version</code></pre>
702709
</details>
703710
</dd>
704711
<dt id="supertokens_python.querier.Querier.send_delete_request"><code class="name flex">
@@ -834,6 +841,7 @@ <h2>Index</h2>
834841
<li>
835842
<h4><code><a title="supertokens_python.querier.Querier" href="#supertokens_python.querier.Querier">Querier</a></code></h4>
836843
<ul class="">
844+
<li><code><a title="supertokens_python.querier.Querier.api_version" href="#supertokens_python.querier.Querier.api_version">api_version</a></code></li>
837845
<li><code><a title="supertokens_python.querier.Querier.get_all_core_urls_for_path" href="#supertokens_python.querier.Querier.get_all_core_urls_for_path">get_all_core_urls_for_path</a></code></li>
838846
<li><code><a title="supertokens_python.querier.Querier.get_api_version" href="#supertokens_python.querier.Querier.get_api_version">get_api_version</a></code></li>
839847
<li><code><a title="supertokens_python.querier.Querier.get_hosts_alive_for_testing" href="#supertokens_python.querier.Querier.get_hosts_alive_for_testing">get_hosts_alive_for_testing</a></code></li>

html/supertokens_python/recipe/emailverification/recipe.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,9 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailverification.recip
383383
except Exception as e:
384384
# This should never happen since we have just set the status above
385385
if str(e) == &#34;UNKNOWN_USER_ID&#34;:
386+
log_debug_message(
387+
&#34;verifyEmailPOST: Returning UNAUTHORISED because the user id provided is unknown&#34;
388+
)
386389
raise_unauthorised_exception(&#34;Unknown User ID provided&#34;)
387390
else:
388391
raise e
@@ -402,6 +405,9 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailverification.recip
402405
await session.fetch_and_set_claim(EmailVerificationClaim, user_context)
403406
except Exception as e:
404407
if str(e) == &#34;UNKNOWN_USER_ID&#34;:
408+
log_debug_message(
409+
&#34;isEmailVerifiedGET: Returning UNAUTHORISED because the user id provided is unknown&#34;
410+
)
405411
raise_unauthorised_exception(&#34;Unknown User ID provided&#34;)
406412
else:
407413
raise e
@@ -483,6 +489,9 @@ <h1 class="title">Module <code>supertokens_python.recipe.emailverification.recip
483489
)
484490
return GenerateEmailVerifyTokenPostOkResult()
485491

492+
log_debug_message(
493+
&#34;generateEmailVerifyTokenPOST: Returning UNAUTHORISED because the user id provided is unknown&#34;
494+
)
486495
raise_unauthorised_exception(&#34;Unknown User ID provided&#34;)
487496

488497

@@ -568,6 +577,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
568577
except Exception as e:
569578
# This should never happen since we have just set the status above
570579
if str(e) == &#34;UNKNOWN_USER_ID&#34;:
580+
log_debug_message(
581+
&#34;verifyEmailPOST: Returning UNAUTHORISED because the user id provided is unknown&#34;
582+
)
571583
raise_unauthorised_exception(&#34;Unknown User ID provided&#34;)
572584
else:
573585
raise e
@@ -587,6 +599,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
587599
await session.fetch_and_set_claim(EmailVerificationClaim, user_context)
588600
except Exception as e:
589601
if str(e) == &#34;UNKNOWN_USER_ID&#34;:
602+
log_debug_message(
603+
&#34;isEmailVerifiedGET: Returning UNAUTHORISED because the user id provided is unknown&#34;
604+
)
590605
raise_unauthorised_exception(&#34;Unknown User ID provided&#34;)
591606
else:
592607
raise e
@@ -668,6 +683,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
668683
)
669684
return GenerateEmailVerifyTokenPostOkResult()
670685

686+
log_debug_message(
687+
&#34;generateEmailVerifyTokenPOST: Returning UNAUTHORISED because the user id provided is unknown&#34;
688+
)
671689
raise_unauthorised_exception(&#34;Unknown User ID provided&#34;)</code></pre>
672690
</details>
673691
<h3>Ancestors</h3>
@@ -706,6 +724,9 @@ <h3>Methods</h3>
706724
except Exception as e:
707725
# This should never happen since we have just set the status above
708726
if str(e) == &#34;UNKNOWN_USER_ID&#34;:
727+
log_debug_message(
728+
&#34;verifyEmailPOST: Returning UNAUTHORISED because the user id provided is unknown&#34;
729+
)
709730
raise_unauthorised_exception(&#34;Unknown User ID provided&#34;)
710731
else:
711732
raise e
@@ -789,6 +810,9 @@ <h3>Methods</h3>
789810
)
790811
return GenerateEmailVerifyTokenPostOkResult()
791812

813+
log_debug_message(
814+
&#34;generateEmailVerifyTokenPOST: Returning UNAUTHORISED because the user id provided is unknown&#34;
815+
)
792816
raise_unauthorised_exception(&#34;Unknown User ID provided&#34;)</code></pre>
793817
</details>
794818
</dd>
@@ -813,6 +837,9 @@ <h3>Methods</h3>
813837
await session.fetch_and_set_claim(EmailVerificationClaim, user_context)
814838
except Exception as e:
815839
if str(e) == &#34;UNKNOWN_USER_ID&#34;:
840+
log_debug_message(
841+
&#34;isEmailVerifiedGET: Returning UNAUTHORISED because the user id provided is unknown&#34;
842+
)
816843
raise_unauthorised_exception(&#34;Unknown User ID provided&#34;)
817844
else:
818845
raise e

html/supertokens_python/recipe/session/access_token.html

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ <h1 class="title">Module <code>supertokens_python.recipe.session.access_token</c
155155
}
156156
except Exception as e:
157157
log_debug_message(
158-
&#34;getSession: Returning TRY_REFRESH_TOKEN because failed to decode access token&#34;
158+
&#34;getInfoFromAccessToken: Returning TRY_REFRESH_TOKEN because access token validation failed - %s&#34;,
159+
e,
159160
)
160161
raise_try_refresh_token_exception(e)
161162

@@ -169,6 +170,10 @@ <h1 class="title">Module <code>supertokens_python.recipe.session.access_token</c
169170
or not isinstance(payload.get(&#34;sessionHandle&#34;), str)
170171
or not isinstance(payload.get(&#34;refreshTokenHash1&#34;), str)
171172
):
173+
log_debug_message(
174+
&#34;validateAccessTokenStructure: Access token is using version &gt;= 3&#34;
175+
)
176+
# The error message below will be logged by the error handler that translates this into a TRY_REFRESH_TOKEN_ERROR
172177
raise Exception(
173178
&#34;Access token does not contain all the information. Maybe the structure has changed?&#34;
174179
)
@@ -179,6 +184,10 @@ <h1 class="title">Module <code>supertokens_python.recipe.session.access_token</c
179184
or not isinstance(payload.get(&#34;expiryTime&#34;), int)
180185
or not isinstance(payload.get(&#34;timeCreated&#34;), int)
181186
):
187+
log_debug_message(
188+
&#34;validateAccessTokenStructure: Access token is using version &lt; 3&#34;
189+
)
190+
# The error message below will be logged by the error handler that translates this into a TRY_REFRESH_TOKEN_ERROR
182191
raise Exception(
183192
&#34;Access token does not contain all the information. Maybe the structure has changed?&#34;
184193
)</code></pre>
@@ -284,7 +293,8 @@ <h2 class="section-title" id="header-functions">Functions</h2>
284293
}
285294
except Exception as e:
286295
log_debug_message(
287-
&#34;getSession: Returning TRY_REFRESH_TOKEN because failed to decode access token&#34;
296+
&#34;getInfoFromAccessToken: Returning TRY_REFRESH_TOKEN because access token validation failed - %s&#34;,
297+
e,
288298
)
289299
raise_try_refresh_token_exception(e)</code></pre>
290300
</details>
@@ -342,6 +352,10 @@ <h2 class="section-title" id="header-functions">Functions</h2>
342352
or not isinstance(payload.get(&#34;sessionHandle&#34;), str)
343353
or not isinstance(payload.get(&#34;refreshTokenHash1&#34;), str)
344354
):
355+
log_debug_message(
356+
&#34;validateAccessTokenStructure: Access token is using version &gt;= 3&#34;
357+
)
358+
# The error message below will be logged by the error handler that translates this into a TRY_REFRESH_TOKEN_ERROR
345359
raise Exception(
346360
&#34;Access token does not contain all the information. Maybe the structure has changed?&#34;
347361
)
@@ -352,6 +366,10 @@ <h2 class="section-title" id="header-functions">Functions</h2>
352366
or not isinstance(payload.get(&#34;expiryTime&#34;), int)
353367
or not isinstance(payload.get(&#34;timeCreated&#34;), int)
354368
):
369+
log_debug_message(
370+
&#34;validateAccessTokenStructure: Access token is using version &lt; 3&#34;
371+
)
372+
# The error message below will be logged by the error handler that translates this into a TRY_REFRESH_TOKEN_ERROR
355373
raise Exception(
356374
&#34;Access token does not contain all the information. Maybe the structure has changed?&#34;
357375
)</code></pre>

html/supertokens_python/recipe/session/recipe_implementation.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ <h1 class="title">Module <code>supertokens_python.recipe.session.recipe_implemen
252252
)
253253
return None
254254

255+
log_debug_message(
256+
&#34;getSession: UNAUTHORISED because the accessToken couldn&#39;t be parsed or had an invalid structure&#34;
257+
)
255258
raise UnauthorisedError(&#34;Token parsing failed&#34;, clear_tokens=False)
256259

257260
response = await session_functions.get_session(
@@ -691,6 +694,9 @@ <h2 class="section-title" id="header-classes">Classes</h2>
691694
)
692695
return None
693696

697+
log_debug_message(
698+
&#34;getSession: UNAUTHORISED because the accessToken couldn&#39;t be parsed or had an invalid structure&#34;
699+
)
694700
raise UnauthorisedError(&#34;Token parsing failed&#34;, clear_tokens=False)
695701

696702
response = await session_functions.get_session(
@@ -1152,6 +1158,9 @@ <h3>Methods</h3>
11521158
)
11531159
return None
11541160

1161+
log_debug_message(
1162+
&#34;getSession: UNAUTHORISED because the accessToken couldn&#39;t be parsed or had an invalid structure&#34;
1163+
)
11551164
raise UnauthorisedError(&#34;Token parsing failed&#34;, clear_tokens=False)
11561165

11571166
response = await session_functions.get_session(

0 commit comments

Comments
 (0)