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

Skip to content

Commit a0395a9

Browse files
authored
Merge pull request auth0#297 from GDGSNF/master
2 parents 9e355df + 2714a3a commit a0395a9

File tree

4 files changed

+19
-27
lines changed

4 files changed

+19
-27
lines changed

auth0/v3/authentication/base.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,19 @@ def __init__(self, status_code, content, headers):
7474
self._headers = headers
7575

7676
def content(self):
77-
if self._is_error():
78-
if self._status_code == 429:
79-
reset_at = int(self._headers.get('x-ratelimit-reset', '-1'))
80-
raise RateLimitError(error_code=self._error_code(),
81-
message=self._error_message(),
82-
reset_at=reset_at)
83-
84-
raise Auth0Error(status_code=self._status_code,
85-
error_code=self._error_code(),
86-
message=self._error_message())
87-
else:
77+
if not self._is_error():
8878
return self._content
8979

80+
if self._status_code == 429:
81+
reset_at = int(self._headers.get('x-ratelimit-reset', '-1'))
82+
raise RateLimitError(error_code=self._error_code(),
83+
message=self._error_message(),
84+
reset_at=reset_at)
85+
86+
raise Auth0Error(status_code=self._status_code,
87+
error_code=self._error_code(),
88+
message=self._error_message())
89+
9090
def _is_error(self):
9191
return self._status_code is None or self._status_code >= 400
9292

auth0/v3/authentication/token_verifier.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,13 @@ def _verify_payload(self, payload, nonce=None, max_age=None, organization=None):
271271
raise TokenValidationError('Subject (sub) claim must be a string present in the ID token')
272272

273273
# Audience
274-
if 'aud' not in payload or not (isinstance(payload['aud'], (str, ustr)) or isinstance(payload['aud'], list)):
274+
if 'aud' not in payload or not isinstance(
275+
payload['aud'], (str, ustr, list)
276+
):
275277
raise TokenValidationError(
276278
'Audience (aud) claim must be a string or array of strings present in the ID token')
277279

278-
if isinstance(payload['aud'], list) and not self.aud in payload['aud']:
280+
if isinstance(payload['aud'], list) and self.aud not in payload['aud']:
279281
payload_audiences = ", ".join(payload['aud'])
280282
raise TokenValidationError(
281283
'Audience (aud) claim mismatch in the ID token; expected "{}" but was '

auth0/v3/management/organizations.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,7 @@ def all_organization_connections(self, id, page=None, per_page=None):
143143
144144
See: https://auth0.com/docs/api/management/v2#!/Organizations/get_enabled_connections
145145
"""
146-
params = {}
147-
params['page'] = page
148-
params['per_page'] = per_page
149-
146+
params = {'page': page, 'per_page': per_page}
150147
return self.client.get(self._url(id, 'enabled_connections'), params=params)
151148

152149
def get_organization_connection(self, id, connection_id):
@@ -282,10 +279,7 @@ def all_organization_member_roles(self, id, user_id, page=None, per_page=None):
282279
283280
See: https://auth0.com/docs/api/management/v2#!/Organizations/get_organization_member_roles
284281
"""
285-
params = {}
286-
params['page'] = page
287-
params['per_page'] = per_page
288-
282+
params = {'page': page, 'per_page': per_page}
289283
return self.client.get(self._url(id, 'members', user_id, 'roles'), params=params)
290284

291285
def create_organization_member_roles(self, id, user_id, body):
@@ -334,10 +328,7 @@ def all_organization_invitations(self, id, page=None, per_page=None):
334328
335329
See: https://auth0.com/docs/api/management/v2#!/Organizations/get_invitations
336330
"""
337-
params = {}
338-
params['page'] = page
339-
params['per_page'] = per_page
340-
331+
params = {'page': page, 'per_page': per_page}
341332
return self.client.get(self._url(id, 'invitations'), params=params)
342333

343334
def get_organization_invitation(self, id, invitaton_id):

auth0/v3/management/users_by_email.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def __init__(self, domain, token, telemetry=True, timeout=5.0, protocol="https",
2929
self.client = RestClient(jwt=token, telemetry=telemetry, timeout=timeout, options=rest_options)
3030

3131
def _url(self):
32-
url = '{}://{}/api/v2/users-by-email'.format(self.protocol, self.domain)
33-
return url
32+
return '{}://{}/api/v2/users-by-email'.format(self.protocol, self.domain)
3433

3534
def search_users_by_email(self, email, fields=None, include_fields=True):
3635
"""List or search users.

0 commit comments

Comments
 (0)