Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b92344b

Browse files
committed
Remove a couple of py2 references
1 parent 158ae05 commit b92344b

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

EXAMPLES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ resets is exposed in the `reset_at` property. When the header is unset, this val
145145

146146
### Asynchronous environments
147147

148-
This SDK provides async methods built on top of [asyncio](https://docs.python.org/3/library/asyncio.html). To make them available you must have Python >=3.6 and the [aiohttp](https://docs.aiohttp.org/en/stable/) module installed.
148+
This SDK provides async methods built on top of [asyncio](https://docs.python.org/3/library/asyncio.html). To make them available you must have the [aiohttp](https://docs.aiohttp.org/en/stable/) module installed.
149149

150150
Then additional methods with the `_async` suffix will be added to modules created by the `management.Auth0` class or to classes that are passed to the `asyncify` method. For example:
151151

auth0/authentication/token_verifier.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,8 @@ def verify(self, token, nonce=None, max_age=None, organization=None):
298298
return payload
299299

300300
def _verify_payload(self, payload, nonce=None, max_age=None, organization=None):
301-
try:
302-
# on Python 2.7, 'str' keys as parsed as 'unicode'
303-
# But 'unicode' was removed on Python 3.7
304-
# noinspection PyUnresolvedReferences
305-
ustr = unicode
306-
except NameError:
307-
ustr = str
308-
309301
# Issuer
310-
if "iss" not in payload or not isinstance(payload["iss"], (str, ustr)):
302+
if "iss" not in payload or not isinstance(payload["iss"], str):
311303
raise TokenValidationError(
312304
"Issuer (iss) claim must be a string present in the ID token"
313305
)
@@ -318,13 +310,13 @@ def _verify_payload(self, payload, nonce=None, max_age=None, organization=None):
318310
)
319311

320312
# Subject
321-
if "sub" not in payload or not isinstance(payload["sub"], (str, ustr)):
313+
if "sub" not in payload or not isinstance(payload["sub"], str):
322314
raise TokenValidationError(
323315
"Subject (sub) claim must be a string present in the ID token"
324316
)
325317

326318
# Audience
327-
if "aud" not in payload or not isinstance(payload["aud"], (str, ustr, list)):
319+
if "aud" not in payload or not isinstance(payload["aud"], (str, list)):
328320
raise TokenValidationError(
329321
"Audience (aud) claim must be a string or array of strings present in"
330322
" the ID token"
@@ -336,7 +328,7 @@ def _verify_payload(self, payload, nonce=None, max_age=None, organization=None):
336328
'Audience (aud) claim mismatch in the ID token; expected "{}" but was '
337329
'not one of "{}"'.format(self.aud, payload_audiences)
338330
)
339-
elif isinstance(payload["aud"], (str, ustr)) and payload["aud"] != self.aud:
331+
elif isinstance(payload["aud"], str) and payload["aud"] != self.aud:
340332
raise TokenValidationError(
341333
'Audience (aud) claim mismatch in the ID token; expected "{}" '
342334
'but found "{}"'.format(self.aud, payload["aud"])
@@ -367,7 +359,7 @@ def _verify_payload(self, payload, nonce=None, max_age=None, organization=None):
367359

368360
# Nonce
369361
if nonce:
370-
if "nonce" not in payload or not isinstance(payload["nonce"], (str, ustr)):
362+
if "nonce" not in payload or not isinstance(payload["nonce"], str):
371363
raise TokenValidationError(
372364
"Nonce (nonce) claim must be a string present in the ID token"
373365
)
@@ -379,9 +371,7 @@ def _verify_payload(self, payload, nonce=None, max_age=None, organization=None):
379371

380372
# Organization
381373
if organization:
382-
if "org_id" not in payload or not isinstance(
383-
payload["org_id"], (str, ustr)
384-
):
374+
if "org_id" not in payload or not isinstance(payload["org_id"], str):
385375
raise TokenValidationError(
386376
"Organization (org_id) claim must be a string present in the ID"
387377
" token"
@@ -394,7 +384,7 @@ def _verify_payload(self, payload, nonce=None, max_age=None, organization=None):
394384

395385
# Authorized party
396386
if isinstance(payload["aud"], list) and len(payload["aud"]) > 1:
397-
if "azp" not in payload or not isinstance(payload["azp"], (str, ustr)):
387+
if "azp" not in payload or not isinstance(payload["azp"], str):
398388
raise TokenValidationError(
399389
"Authorized Party (azp) claim must be a string present in the ID"
400390
" token when Audience (aud) claim has multiple values"

0 commit comments

Comments
 (0)