auth0-python 3.1.4__tar.gz → 3.2.2__tar.gz
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.
- usr/local/lib/python3.6/site-packages/auth0/__init__.py +1 -1
- usr/local/lib/python3.6/site-packages/auth0/__pycache__/__init__.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/__pycache__/__init__.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/__pycache__/exceptions.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/__init__.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/authorize_client.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/base.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/database.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/delegated.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/enterprise.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/get_token.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/logout.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/passwordless.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/social.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/users.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/base.py +72 -7
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/enterprise.py +1 -1
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/get_token.py +1 -1
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/logout.py +1 -1
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/passwordless.py +1 -1
- usr/local/lib/python3.6/site-packages/auth0/v3/authentication/social.py +1 -1
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/__init__.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/auth0.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/blacklists.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/client_grants.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/clients.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/connections.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/device_credentials.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/emails.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/guardian.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/jobs.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/logs.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/resource_servers.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/rest.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/rules.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/stats.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/tenants.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/tickets.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/user_blocks.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/users.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/management/auth0.py +1 -1
- usr/local/lib/python3.6/site-packages/auth0/v3/management/blacklists.py +2 -2
- usr/local/lib/python3.6/site-packages/auth0/v3/management/client_grants.py +1 -1
- usr/local/lib/python3.6/site-packages/auth0/v3/management/clients.py +10 -10
- usr/local/lib/python3.6/site-packages/auth0/v3/management/rest.py +70 -6
- usr/local/lib/python3.6/site-packages/auth0/v3/test/__pycache__/__init__.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/authentication/__pycache__/__init__.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/authentication/__pycache__/test_authorize_client.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/authentication/__pycache__/test_base.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/authentication/__pycache__/test_database.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/authentication/__pycache__/test_delegated.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/authentication/__pycache__/test_enterprise.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/authentication/__pycache__/test_get_token.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/authentication/__pycache__/test_logout.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/authentication/__pycache__/test_passwordless.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/authentication/__pycache__/test_social.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/authentication/__pycache__/test_users.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/authentication/test_base.py +62 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/__init__.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_blacklists.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_client_grants.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_clients.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_connections.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_device_credentials.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_emails.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_guardian.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_jobs.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_logs.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_resource_servers.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_rest.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_rules.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_stats.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_tenants.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_tickets.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_user_blocks.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_users.cpython-36.pyc +0 -0
- usr/local/lib/python3.6/site-packages/auth0/v3/test/management/test_rest.py +71 -1
- usr/local/lib/python3.6/site-packages/{auth0_python-3.1.4-py3.6.egg-info → auth0_python-3.2.2-py3.6.egg-info}/PKG-INFO +3 -2
- /usr/local/lib/python3.6/site-packages/{auth0_python-3.1.4-py3.6.egg-info → auth0_python-3.2.2-py3.6.egg-info}/SOURCES.txt +0 -0
- /usr/local/lib/python3.6/site-packages/{auth0_python-3.1.4-py3.6.egg-info → auth0_python-3.2.2-py3.6.egg-info}/dependency_links.txt +0 -0
- /usr/local/lib/python3.6/site-packages/{auth0_python-3.1.4-py3.6.egg-info → auth0_python-3.2.2-py3.6.egg-info}/requires.txt +0 -0
- /usr/local/lib/python3.6/site-packages/{auth0_python-3.1.4-py3.6.egg-info → auth0_python-3.2.2-py3.6.egg-info}/top_level.txt +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '3.
|
|
1
|
+
__version__ = '3.2.2'
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/__init__.cpython-36.pyc
CHANGED
|
Binary file
|
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/base.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/database.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/delegated.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/enterprise.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/get_token.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/logout.cpython-36.pyc
CHANGED
|
Binary file
|
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/social.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/authentication/__pycache__/users.cpython-36.pyc
CHANGED
|
Binary file
|
|
@@ -3,6 +3,9 @@ import requests
|
|
|
3
3
|
from ..exceptions import Auth0Error
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
UNKNOWN_ERROR = 'a0.sdk.internal.unknown'
|
|
7
|
+
|
|
8
|
+
|
|
6
9
|
class AuthenticationBase(object):
|
|
7
10
|
|
|
8
11
|
def post(self, url, data=None, headers=None):
|
|
@@ -14,13 +17,75 @@ class AuthenticationBase(object):
|
|
|
14
17
|
return requests.get(url=url, params=params, headers=headers).text
|
|
15
18
|
|
|
16
19
|
def _process_response(self, response):
|
|
20
|
+
return self._parse(response).content()
|
|
21
|
+
|
|
22
|
+
def _parse(self, response):
|
|
23
|
+
if not response.text:
|
|
24
|
+
return EmptyResponse(response.status_code)
|
|
17
25
|
try:
|
|
18
|
-
|
|
26
|
+
return JsonResponse(response)
|
|
19
27
|
except ValueError:
|
|
20
|
-
return response
|
|
28
|
+
return PlainResponse(response)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Response(object):
|
|
32
|
+
def __init__(self, status_code, content):
|
|
33
|
+
self._status_code = status_code
|
|
34
|
+
self._content = content
|
|
35
|
+
|
|
36
|
+
def content(self):
|
|
37
|
+
if self._is_error():
|
|
38
|
+
raise Auth0Error(status_code=self._status_code,
|
|
39
|
+
error_code=self._error_code(),
|
|
40
|
+
message=self._error_message())
|
|
41
|
+
else:
|
|
42
|
+
return self._content
|
|
43
|
+
|
|
44
|
+
def _is_error(self):
|
|
45
|
+
return self._status_code is None or self._status_code >= 400
|
|
46
|
+
|
|
47
|
+
# Adding these methods to force implementation in subclasses because they are references in this parent class
|
|
48
|
+
def _error_code(self):
|
|
49
|
+
raise NotImplementedError
|
|
50
|
+
|
|
51
|
+
def _error_message(self):
|
|
52
|
+
raise NotImplementedError
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class JsonResponse(Response):
|
|
56
|
+
def __init__(self, response):
|
|
57
|
+
content = json.loads(response.text)
|
|
58
|
+
super(JsonResponse, self).__init__(response.status_code, content)
|
|
59
|
+
|
|
60
|
+
def _error_code(self):
|
|
61
|
+
if 'error' in self._content:
|
|
62
|
+
return self._content.get('error')
|
|
63
|
+
elif 'code' in self._content:
|
|
64
|
+
return self._content.get('code')
|
|
21
65
|
else:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
66
|
+
return UNKNOWN_ERROR
|
|
67
|
+
|
|
68
|
+
def _error_message(self):
|
|
69
|
+
return self._content.get('error_description', '')
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class PlainResponse(Response):
|
|
73
|
+
def __init__(self, response):
|
|
74
|
+
super(PlainResponse, self).__init__(response.status_code, response.text)
|
|
75
|
+
|
|
76
|
+
def _error_code(self):
|
|
77
|
+
return UNKNOWN_ERROR
|
|
78
|
+
|
|
79
|
+
def _error_message(self):
|
|
80
|
+
return self._content
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class EmptyResponse(Response):
|
|
84
|
+
def __init__(self, status_code):
|
|
85
|
+
super(EmptyResponse, self).__init__(status_code, '')
|
|
86
|
+
|
|
87
|
+
def _error_code(self):
|
|
88
|
+
return UNKNOWN_ERROR
|
|
89
|
+
|
|
90
|
+
def _error_message(self):
|
|
91
|
+
return ''
|
|
@@ -16,7 +16,7 @@ class Enterprise(AuthenticationBase):
|
|
|
16
16
|
"""Get SAML2.0 Metadata.
|
|
17
17
|
|
|
18
18
|
Args:
|
|
19
|
-
client_id (str): Id of the
|
|
19
|
+
client_id (str): Client Id of the application to get the SAML metadata for.
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
22
|
return self.get(url='https://%s/samlp/metadata/%s' % (self.domain,
|
|
@@ -92,7 +92,7 @@ class GetToken(AuthenticationBase):
|
|
|
92
92
|
|
|
93
93
|
This is the OAuth 2.0 grant that server processes utilize in
|
|
94
94
|
order to access an API. Use this endpoint to directly request
|
|
95
|
-
an access_token by using the
|
|
95
|
+
an access_token by using the Application Credentials (a Client Id and
|
|
96
96
|
a Client Secret).
|
|
97
97
|
|
|
98
98
|
Args:
|
|
@@ -24,7 +24,7 @@ class Logout(AuthenticationBase):
|
|
|
24
24
|
The URL should be included in any the appropriate Allowed Logout URLs list:
|
|
25
25
|
|
|
26
26
|
Args:
|
|
27
|
-
client_id (str): The client_id of your
|
|
27
|
+
client_id (str): The client_id of your application.
|
|
28
28
|
|
|
29
29
|
returnTo (str): URL to redirect the user after the logout.
|
|
30
30
|
|
usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/__init__.cpython-36.pyc
CHANGED
|
Binary file
|
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/blacklists.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/client_grants.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/clients.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/connections.cpython-36.pyc
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/guardian.cpython-36.pyc
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/tenants.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/tickets.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/management/__pycache__/user_blocks.cpython-36.pyc
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -23,7 +23,7 @@ class Blacklists(object):
|
|
|
23
23
|
|
|
24
24
|
Args:
|
|
25
25
|
aud (str, optional): The JWT's aud claim. The client_id of the
|
|
26
|
-
|
|
26
|
+
application for which it was issued.
|
|
27
27
|
"""
|
|
28
28
|
|
|
29
29
|
params = {
|
|
@@ -38,7 +38,7 @@ class Blacklists(object):
|
|
|
38
38
|
Args:
|
|
39
39
|
jti (str): the jti of the JWT to blacklist.
|
|
40
40
|
aud (str, optional): The JWT's aud claim. The client_id of the
|
|
41
|
-
|
|
41
|
+
application for which it was issued.
|
|
42
42
|
"""
|
|
43
43
|
|
|
44
44
|
return self.client.post(self.url, data={'jti': jti, 'aud': aud})
|
|
@@ -3,7 +3,7 @@ from .rest import RestClient
|
|
|
3
3
|
|
|
4
4
|
class Clients(object):
|
|
5
5
|
|
|
6
|
-
"""Auth0
|
|
6
|
+
"""Auth0 applications endpoints
|
|
7
7
|
|
|
8
8
|
Args:
|
|
9
9
|
domain (str): Your Auth0 domain, e.g: 'username.auth0.com'
|
|
@@ -25,7 +25,7 @@ class Clients(object):
|
|
|
25
25
|
return url
|
|
26
26
|
|
|
27
27
|
def all(self, fields=[], include_fields=True):
|
|
28
|
-
"""Retrieves a list of all
|
|
28
|
+
"""Retrieves a list of all the applications.
|
|
29
29
|
|
|
30
30
|
Important: The client_secret and encryption_key attributes can only be
|
|
31
31
|
retrieved with the read:client_keys scope.
|
|
@@ -45,23 +45,23 @@ class Clients(object):
|
|
|
45
45
|
return self.client.get(self._url(), params=params)
|
|
46
46
|
|
|
47
47
|
def create(self, body):
|
|
48
|
-
"""Create a new
|
|
48
|
+
"""Create a new application.
|
|
49
49
|
|
|
50
50
|
Args:
|
|
51
|
-
body (dict): Attributes for the new
|
|
51
|
+
body (dict): Attributes for the new application.
|
|
52
52
|
See: https://auth0.com/docs/api/v2#!/Clients/post_clients
|
|
53
53
|
"""
|
|
54
54
|
|
|
55
55
|
return self.client.post(self._url(), data=body)
|
|
56
56
|
|
|
57
57
|
def get(self, id, fields=[], include_fields=True):
|
|
58
|
-
"""Retrieves
|
|
58
|
+
"""Retrieves an application by its id.
|
|
59
59
|
|
|
60
60
|
Important: The client_secret, encryption_key and signing_keys
|
|
61
61
|
attributes can only be retrieved with the read:client_keys scope.
|
|
62
62
|
|
|
63
63
|
Args:
|
|
64
|
-
id (str): Id of the
|
|
64
|
+
id (str): Id of the application to get.
|
|
65
65
|
|
|
66
66
|
fields (list of str, optional): A list of fields to include or
|
|
67
67
|
exclude from the result (depending on include_fields). Empty to
|
|
@@ -77,22 +77,22 @@ class Clients(object):
|
|
|
77
77
|
return self.client.get(self._url(id), params=params)
|
|
78
78
|
|
|
79
79
|
def delete(self, id):
|
|
80
|
-
"""Deletes
|
|
80
|
+
"""Deletes an application and all its related assets.
|
|
81
81
|
|
|
82
82
|
Args:
|
|
83
|
-
id (str): Id of
|
|
83
|
+
id (str): Id of application to delete.
|
|
84
84
|
"""
|
|
85
85
|
|
|
86
86
|
return self.client.delete(self._url(id))
|
|
87
87
|
|
|
88
88
|
def update(self, id, body):
|
|
89
|
-
"""Modifies
|
|
89
|
+
"""Modifies an application.
|
|
90
90
|
|
|
91
91
|
Important: The client_secret, encryption_key and signing_keys
|
|
92
92
|
attributes can only be updated with the update:client_keys scope.
|
|
93
93
|
|
|
94
94
|
Args:
|
|
95
|
-
id (str): Client id.
|
|
95
|
+
id (str): Client id of the application.
|
|
96
96
|
|
|
97
97
|
body (dict): Attributes to modify.
|
|
98
98
|
"""
|
|
@@ -5,6 +5,9 @@ import requests
|
|
|
5
5
|
from ..exceptions import Auth0Error
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
UNKNOWN_ERROR = 'a0.sdk.internal.unknown'
|
|
9
|
+
|
|
10
|
+
|
|
8
11
|
class RestClient(object):
|
|
9
12
|
|
|
10
13
|
"""Provides simple methods for handling all RESTful api endpoints. """
|
|
@@ -103,10 +106,71 @@ class RestClient(object):
|
|
|
103
106
|
return self._process_response(response)
|
|
104
107
|
|
|
105
108
|
def _process_response(self, response):
|
|
106
|
-
|
|
109
|
+
return self._parse(response).content()
|
|
110
|
+
|
|
111
|
+
def _parse(self, response):
|
|
112
|
+
if not response.text:
|
|
113
|
+
return EmptyResponse(response.status_code)
|
|
114
|
+
try:
|
|
115
|
+
return JsonResponse(response)
|
|
116
|
+
except ValueError:
|
|
117
|
+
return PlainResponse(response)
|
|
118
|
+
|
|
119
|
+
class Response(object):
|
|
120
|
+
def __init__(self, status_code, content):
|
|
121
|
+
self._status_code = status_code
|
|
122
|
+
self._content = content
|
|
123
|
+
|
|
124
|
+
def content(self):
|
|
125
|
+
if self._is_error():
|
|
126
|
+
raise Auth0Error(status_code=self._status_code,
|
|
127
|
+
error_code=self._error_code(),
|
|
128
|
+
message=self._error_message())
|
|
129
|
+
else:
|
|
130
|
+
return self._content
|
|
131
|
+
|
|
132
|
+
def _is_error(self):
|
|
133
|
+
return self._status_code is None or self._status_code >= 400
|
|
134
|
+
|
|
135
|
+
# Adding these methods to force implementation in subclasses because they are references in this parent class
|
|
136
|
+
def _error_code(self):
|
|
137
|
+
raise NotImplementedError
|
|
138
|
+
|
|
139
|
+
def _error_message(self):
|
|
140
|
+
raise NotImplementedError
|
|
141
|
+
|
|
142
|
+
class JsonResponse(Response):
|
|
143
|
+
def __init__(self, response):
|
|
144
|
+
content = json.loads(response.text)
|
|
145
|
+
super(JsonResponse, self).__init__(response.status_code, content)
|
|
146
|
+
|
|
147
|
+
def _error_code(self):
|
|
148
|
+
if 'errorCode' in self._content:
|
|
149
|
+
return self._content.get('errorCode')
|
|
150
|
+
elif 'error' in self._content:
|
|
151
|
+
return self._content.get('error')
|
|
152
|
+
else:
|
|
153
|
+
return UNKNOWN_ERROR
|
|
154
|
+
|
|
155
|
+
def _error_message(self):
|
|
156
|
+
return self._content.get('error', self._content.get('message', ''))
|
|
157
|
+
|
|
158
|
+
class PlainResponse(Response):
|
|
159
|
+
def __init__(self, response):
|
|
160
|
+
super(PlainResponse, self).__init__(response.status_code, response.text)
|
|
161
|
+
|
|
162
|
+
def _error_code(self):
|
|
163
|
+
return UNKNOWN_ERROR
|
|
164
|
+
|
|
165
|
+
def _error_message(self):
|
|
166
|
+
return self._content
|
|
167
|
+
|
|
168
|
+
class EmptyResponse(Response):
|
|
169
|
+
def __init__(self, status_code):
|
|
170
|
+
super(EmptyResponse, self).__init__(status_code, '')
|
|
171
|
+
|
|
172
|
+
def _error_code(self):
|
|
173
|
+
return UNKNOWN_ERROR
|
|
107
174
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
error_code=text['errorCode'],
|
|
111
|
-
message=text['message'])
|
|
112
|
-
return text
|
|
175
|
+
def _error_message(self):
|
|
176
|
+
return ''
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -35,3 +35,65 @@ class TestBase(unittest.TestCase):
|
|
|
35
35
|
self.assertEqual(context.exception.status_code, error_status)
|
|
36
36
|
self.assertEqual(context.exception.error_code, 'e0')
|
|
37
37
|
self.assertEqual(context.exception.message, 'desc')
|
|
38
|
+
|
|
39
|
+
@mock.patch('requests.post')
|
|
40
|
+
def test_post_error_with_code_property(self, mock_post):
|
|
41
|
+
ab = AuthenticationBase()
|
|
42
|
+
|
|
43
|
+
for error_status in [400, 500, None]:
|
|
44
|
+
mock_post.return_value.status_code = error_status
|
|
45
|
+
mock_post.return_value.text = '{"code": "e0",' \
|
|
46
|
+
'"error_description": "desc"}'
|
|
47
|
+
|
|
48
|
+
with self.assertRaises(Auth0Error) as context:
|
|
49
|
+
data = ab.post('the-url', data={'a': 'b'}, headers={'c': 'd'})
|
|
50
|
+
|
|
51
|
+
self.assertEqual(context.exception.status_code, error_status)
|
|
52
|
+
self.assertEqual(context.exception.error_code, 'e0')
|
|
53
|
+
self.assertEqual(context.exception.message, 'desc')
|
|
54
|
+
|
|
55
|
+
@mock.patch('requests.post')
|
|
56
|
+
def test_post_error_with_no_error_code(self, mock_post):
|
|
57
|
+
ab = AuthenticationBase()
|
|
58
|
+
|
|
59
|
+
for error_status in [400, 500, None]:
|
|
60
|
+
mock_post.return_value.status_code = error_status
|
|
61
|
+
mock_post.return_value.text = '{"error_description": "desc"}'
|
|
62
|
+
|
|
63
|
+
with self.assertRaises(Auth0Error) as context:
|
|
64
|
+
data = ab.post('the-url', data={'a': 'b'}, headers={'c': 'd'})
|
|
65
|
+
|
|
66
|
+
self.assertEqual(context.exception.status_code, error_status)
|
|
67
|
+
self.assertEqual(context.exception.error_code, 'a0.sdk.internal.unknown')
|
|
68
|
+
self.assertEqual(context.exception.message, 'desc')
|
|
69
|
+
|
|
70
|
+
@mock.patch('requests.post')
|
|
71
|
+
def test_post_error_with_text_response(self, mock_post):
|
|
72
|
+
ab = AuthenticationBase()
|
|
73
|
+
|
|
74
|
+
for error_status in [400, 500, None]:
|
|
75
|
+
mock_post.return_value.status_code = error_status
|
|
76
|
+
mock_post.return_value.text = 'there has been a terrible error'
|
|
77
|
+
|
|
78
|
+
with self.assertRaises(Auth0Error) as context:
|
|
79
|
+
data = ab.post('the-url', data={'a': 'b'}, headers={'c': 'd'})
|
|
80
|
+
|
|
81
|
+
self.assertEqual(context.exception.status_code, error_status)
|
|
82
|
+
self.assertEqual(context.exception.error_code, 'a0.sdk.internal.unknown')
|
|
83
|
+
self.assertEqual(context.exception.message,
|
|
84
|
+
'there has been a terrible error')
|
|
85
|
+
|
|
86
|
+
@mock.patch('requests.post')
|
|
87
|
+
def test_post_error_with_no_response_text(self, mock_post):
|
|
88
|
+
ab = AuthenticationBase()
|
|
89
|
+
|
|
90
|
+
for error_status in [400, 500, None]:
|
|
91
|
+
mock_post.return_value.status_code = error_status
|
|
92
|
+
mock_post.return_value.text = None
|
|
93
|
+
|
|
94
|
+
with self.assertRaises(Auth0Error) as context:
|
|
95
|
+
data = ab.post('the-url', data={'a': 'b'}, headers={'c': 'd'})
|
|
96
|
+
|
|
97
|
+
self.assertEqual(context.exception.status_code, error_status)
|
|
98
|
+
self.assertEqual(context.exception.error_code, 'a0.sdk.internal.unknown')
|
|
99
|
+
self.assertEqual(context.exception.message, '')
|
usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/__init__.cpython-36.pyc
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_jobs.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_logs.cpython-36.pyc
CHANGED
|
Binary file
|
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_rest.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_rules.cpython-36.pyc
CHANGED
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_stats.cpython-36.pyc
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
usr/local/lib/python3.6/site-packages/auth0/v3/test/management/__pycache__/test_users.cpython-36.pyc
CHANGED
|
Binary file
|
|
@@ -13,6 +13,7 @@ class TestRest(unittest.TestCase):
|
|
|
13
13
|
headers = {'Authorization': 'Bearer a-token'}
|
|
14
14
|
|
|
15
15
|
mock_get.return_value.text = '["a", "b"]'
|
|
16
|
+
mock_get.return_value.status_code = 200
|
|
16
17
|
|
|
17
18
|
response = rc.get('the-url')
|
|
18
19
|
mock_get.assert_called_with('the-url', params={}, headers=headers)
|
|
@@ -27,7 +28,7 @@ class TestRest(unittest.TestCase):
|
|
|
27
28
|
|
|
28
29
|
mock_get.return_value.text = ''
|
|
29
30
|
response = rc.get('the/url')
|
|
30
|
-
self.assertEqual(response,
|
|
31
|
+
self.assertEqual(response, '')
|
|
31
32
|
|
|
32
33
|
@mock.patch('requests.get')
|
|
33
34
|
def test_get_errors(self, mock_get):
|
|
@@ -37,6 +38,7 @@ class TestRest(unittest.TestCase):
|
|
|
37
38
|
mock_get.return_value.text = '{"statusCode": 999,' \
|
|
38
39
|
' "errorCode": "code",' \
|
|
39
40
|
' "message": "message"}'
|
|
41
|
+
mock_get.return_value.status_code = 999
|
|
40
42
|
|
|
41
43
|
with self.assertRaises(Auth0Error) as context:
|
|
42
44
|
rc.get('the/url')
|
|
@@ -55,6 +57,7 @@ class TestRest(unittest.TestCase):
|
|
|
55
57
|
|
|
56
58
|
data = {'some': 'data'}
|
|
57
59
|
|
|
60
|
+
mock_post.return_value.status_code = 200
|
|
58
61
|
response = rc.post('the/url', data=data)
|
|
59
62
|
mock_post.assert_called_with('the/url', data=json.dumps(data),
|
|
60
63
|
headers=headers)
|
|
@@ -68,6 +71,7 @@ class TestRest(unittest.TestCase):
|
|
|
68
71
|
mock_post.return_value.text = '{"statusCode": 999,' \
|
|
69
72
|
' "errorCode": "code",' \
|
|
70
73
|
' "message": "message"}'
|
|
74
|
+
mock_post.return_value.status_code = 999
|
|
71
75
|
|
|
72
76
|
with self.assertRaises(Auth0Error) as context:
|
|
73
77
|
rc.post('the-url')
|
|
@@ -76,6 +80,68 @@ class TestRest(unittest.TestCase):
|
|
|
76
80
|
self.assertEqual(context.exception.error_code, 'code')
|
|
77
81
|
self.assertEqual(context.exception.message, 'message')
|
|
78
82
|
|
|
83
|
+
@mock.patch('requests.post')
|
|
84
|
+
def test_post_error_with_code_property(self, mock_post):
|
|
85
|
+
rc = RestClient(jwt='a-token', telemetry=False)
|
|
86
|
+
|
|
87
|
+
for error_status in [400, 500, None]:
|
|
88
|
+
mock_post.return_value.status_code = error_status
|
|
89
|
+
mock_post.return_value.text = '{"errorCode": "e0",' \
|
|
90
|
+
'"message": "desc"}'
|
|
91
|
+
|
|
92
|
+
with self.assertRaises(Auth0Error) as context:
|
|
93
|
+
rc.post('the-url')
|
|
94
|
+
|
|
95
|
+
self.assertEqual(context.exception.status_code, error_status)
|
|
96
|
+
self.assertEqual(context.exception.error_code, 'e0')
|
|
97
|
+
self.assertEqual(context.exception.message, 'desc')
|
|
98
|
+
|
|
99
|
+
@mock.patch('requests.post')
|
|
100
|
+
def test_post_error_with_no_error_code(self, mock_post):
|
|
101
|
+
rc = RestClient(jwt='a-token', telemetry=False)
|
|
102
|
+
|
|
103
|
+
for error_status in [400, 500, None]:
|
|
104
|
+
mock_post.return_value.status_code = error_status
|
|
105
|
+
mock_post.return_value.text = '{"message": "desc"}'
|
|
106
|
+
|
|
107
|
+
with self.assertRaises(Auth0Error) as context:
|
|
108
|
+
rc.post('the-url')
|
|
109
|
+
|
|
110
|
+
self.assertEqual(context.exception.status_code, error_status)
|
|
111
|
+
self.assertEqual(context.exception.error_code, 'a0.sdk.internal.unknown')
|
|
112
|
+
self.assertEqual(context.exception.message, 'desc')
|
|
113
|
+
|
|
114
|
+
@mock.patch('requests.post')
|
|
115
|
+
def test_post_error_with_text_response(self, mock_post):
|
|
116
|
+
rc = RestClient(jwt='a-token', telemetry=False)
|
|
117
|
+
|
|
118
|
+
for error_status in [400, 500, None]:
|
|
119
|
+
mock_post.return_value.status_code = error_status
|
|
120
|
+
mock_post.return_value.text = 'there has been a terrible error'
|
|
121
|
+
|
|
122
|
+
with self.assertRaises(Auth0Error) as context:
|
|
123
|
+
rc.post('the-url')
|
|
124
|
+
|
|
125
|
+
self.assertEqual(context.exception.status_code, error_status)
|
|
126
|
+
self.assertEqual(context.exception.error_code, 'a0.sdk.internal.unknown')
|
|
127
|
+
self.assertEqual(context.exception.message,
|
|
128
|
+
'there has been a terrible error')
|
|
129
|
+
|
|
130
|
+
@mock.patch('requests.post')
|
|
131
|
+
def test_post_error_with_no_response_text(self, mock_post):
|
|
132
|
+
rc = RestClient(jwt='a-token', telemetry=False)
|
|
133
|
+
|
|
134
|
+
for error_status in [400, 500, None]:
|
|
135
|
+
mock_post.return_value.status_code = error_status
|
|
136
|
+
mock_post.return_value.text = None
|
|
137
|
+
|
|
138
|
+
with self.assertRaises(Auth0Error) as context:
|
|
139
|
+
rc.post('the-url')
|
|
140
|
+
|
|
141
|
+
self.assertEqual(context.exception.status_code, error_status)
|
|
142
|
+
self.assertEqual(context.exception.error_code, 'a0.sdk.internal.unknown')
|
|
143
|
+
self.assertEqual(context.exception.message, '')
|
|
144
|
+
|
|
79
145
|
@mock.patch('requests.patch')
|
|
80
146
|
def test_patch(self, mock_patch):
|
|
81
147
|
rc = RestClient(jwt='a-token', telemetry=False)
|
|
@@ -83,6 +149,7 @@ class TestRest(unittest.TestCase):
|
|
|
83
149
|
'Content-Type': 'application/json'}
|
|
84
150
|
|
|
85
151
|
mock_patch.return_value.text = '["a", "b"]'
|
|
152
|
+
mock_patch.return_value.status_code = 200
|
|
86
153
|
|
|
87
154
|
data = {'some': 'data'}
|
|
88
155
|
|
|
@@ -99,6 +166,7 @@ class TestRest(unittest.TestCase):
|
|
|
99
166
|
mock_patch.return_value.text = '{"statusCode": 999,' \
|
|
100
167
|
' "errorCode": "code",' \
|
|
101
168
|
' "message": "message"}'
|
|
169
|
+
mock_patch.return_value.status_code = 999
|
|
102
170
|
|
|
103
171
|
with self.assertRaises(Auth0Error) as context:
|
|
104
172
|
rc.patch(url='the/url')
|
|
@@ -113,6 +181,7 @@ class TestRest(unittest.TestCase):
|
|
|
113
181
|
headers = {'Authorization': 'Bearer a-token'}
|
|
114
182
|
|
|
115
183
|
mock_delete.return_value.text = '["a", "b"]'
|
|
184
|
+
mock_delete.return_value.status_code = 200
|
|
116
185
|
|
|
117
186
|
response = rc.delete(url='the-url/ID')
|
|
118
187
|
mock_delete.assert_called_with('the-url/ID', headers=headers, params={})
|
|
@@ -126,6 +195,7 @@ class TestRest(unittest.TestCase):
|
|
|
126
195
|
mock_delete.return_value.text = '{"statusCode": 999,' \
|
|
127
196
|
' "errorCode": "code",' \
|
|
128
197
|
' "message": "message"}'
|
|
198
|
+
mock_delete.return_value.status_code = 999
|
|
129
199
|
|
|
130
200
|
with self.assertRaises(Auth0Error) as context:
|
|
131
201
|
rc.delete(url='the-url')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version:
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: auth0-python
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.2
|
|
4
4
|
Summary: Auth0 Python SDK
|
|
5
5
|
Home-page: https://github.com/auth0/auth0-python
|
|
6
6
|
Author: Auth0
|
|
@@ -18,3 +18,4 @@ Classifier: Programming Language :: Python :: 3.2
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.3
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.4
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.5
|
|
21
|
+
Provides-Extra: test
|
|
File without changes
|
|
File without changes
|
|
File without changes
|