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

Skip to content

Commit b9e2387

Browse files
committed
Remove deprecated methods
1 parent 0a2dc94 commit b9e2387

File tree

12 files changed

+28
-230
lines changed

12 files changed

+28
-230
lines changed

V4_MIGRATION_GUIDE.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
Guide to migrating from `3.x` to `4.x`
44

5-
- [Python <3.6 is no longer supported](#python-36-is-no-longer-supported)
5+
- [Python <3.7 is no longer supported](#python-37-is-no-longer-supported)
66
- [Client ID and client secret are now specified in the constructor for authentication clients](#client-id-and-client-secret-are-now-specified-in-the-constructor-for-authentication-clients)
77
- [AuthorizeClient and Logout have been removed](#authorizeclient-and-logout-have-been-removed)
8+
- [Methods that call deprecated endpoints have been removed](#methods-that-call-deprecated-endpoints-have-been-removed)
89

9-
## Python <3.6 is no longer supported
10+
## Python <3.7 is no longer supported
1011

11-
Python 3.5 and Python 2 are EOL and are no longer supported.
12+
Python <=3.6 and Python 2 are EOL and are no longer supported.
1213

1314
## Client ID and client secret are now specified in the constructor for authentication clients
1415

@@ -35,4 +36,19 @@ get_token.client_credentials('my-api')
3536

3637
## AuthorizeClient and Logout have been removed
3738

38-
The authorize and logout requests need to be done in a user agent, so it didn't make sense to include them in a REST client.
39+
The authorize and logout requests need to be done in a user agent, so it didn't make sense to include them in a REST client.
40+
41+
## Methods that call deprecated endpoints have been removed
42+
43+
The following methods have been removed:
44+
45+
### Authentication
46+
47+
- `database.login` - Use `get_token.login`
48+
- `passwordless.sms_login` - Use `get_token.passwordless_login`
49+
- `users.tokeninfo` - `users.userinfo`
50+
51+
### Management
52+
53+
- `users.delete_all_users` - Use `users.delete`
54+
- `jobs.get_results` - Use `jobs.get`

auth0/v3/authentication/database.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,6 @@ class Database(AuthenticationBase):
1010
domain (str): Your auth0 domain (e.g: username.auth0.com)
1111
"""
1212

13-
def login(
14-
self,
15-
username,
16-
password,
17-
connection,
18-
id_token=None,
19-
grant_type="password",
20-
device=None,
21-
scope="openid",
22-
):
23-
"""Login using username and password
24-
25-
Given the user credentials and the connection specified, it will do
26-
the authentication on the provider and return a dict with the
27-
access_token and id_token. This endpoint only works for database
28-
connections, passwordless connections, Active Directory/LDAP,
29-
Windows Azure AD and ADFS.
30-
"""
31-
warnings.warn(
32-
"/oauth/ro will be deprecated in future releases", DeprecationWarning
33-
)
34-
35-
body = {
36-
"client_id": self.client_id,
37-
"username": username,
38-
"password": password,
39-
"connection": connection,
40-
"grant_type": grant_type,
41-
"scope": scope,
42-
}
43-
if id_token:
44-
body.update({"id_token": id_token})
45-
if device:
46-
body.update({"device": device})
47-
return self.post(
48-
"{}://{}/oauth/ro".format(self.protocol, self.domain), data=body
49-
)
50-
5113
def signup(
5214
self,
5315
email,

auth0/v3/authentication/passwordless.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,3 @@ def sms(self, phone_number):
7070
return self.authenticated_post(
7171
"{}://{}/passwordless/start".format(self.protocol, self.domain), data=data
7272
)
73-
74-
def sms_login(self, phone_number, code, scope="openid"):
75-
"""Login using phone number/verification code.
76-
77-
Args:
78-
phone_number (str): Phone number.
79-
80-
code (str): Code received in the SMS.
81-
82-
scope (str, optional): Scope to use. Defaults to 'openid'.
83-
"""
84-
warnings.warn(
85-
"/oauth/ro will be deprecated in future releases", DeprecationWarning
86-
)
87-
88-
return self.post(
89-
"{}://{}/oauth/ro".format(self.protocol, self.domain),
90-
data={
91-
"client_id": self.client_id,
92-
"connection": "sms",
93-
"grant_type": "password",
94-
"username": phone_number,
95-
"password": code,
96-
"scope": scope,
97-
},
98-
)

auth0/v3/authentication/users.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,3 @@ def userinfo(self, access_token):
4949
url="{}://{}/userinfo".format(self.protocol, self.domain),
5050
headers={"Authorization": "Bearer {}".format(access_token)},
5151
)
52-
53-
def tokeninfo(self, jwt):
54-
55-
"""Returns user profile based on the user's jwt
56-
57-
Validates a JSON Web Token (signature and expiration) and returns the
58-
user information associated with the user id (sub property) of
59-
the token.
60-
61-
Args:
62-
jwt (str): User's jwt
63-
64-
Returns:
65-
The user profile.
66-
"""
67-
warnings.warn(
68-
"/tokeninfo will be deprecated in future releases", DeprecationWarning
69-
)
70-
return self.client.post(
71-
url="{}://{}/tokeninfo".format(self.protocol, self.domain),
72-
data={"id_token": jwt},
73-
)

auth0/v3/management/jobs.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,6 @@ def get_failed_job(self, id):
6767
url = self._url("{}/errors".format(id))
6868
return self.client.get(url)
6969

70-
def get_results(self, job_id):
71-
"""Get results of a job
72-
73-
Args:
74-
job_id (str): The id of the job.
75-
76-
Deprecation:
77-
The /jobs/{id}/results endpoint was removed from the Management API.
78-
You can obtain the Job results by querying a Job by ID.
79-
80-
See: https://auth0.com/docs/api/management/v2#!/Jobs/get_jobs_by_id
81-
"""
82-
warnings.warn(
83-
"/jobs/{id}/results is no longer available. The get(id) function will be"
84-
" called instead.",
85-
DeprecationWarning,
86-
)
87-
return self.get(job_id)
88-
8970
def export_users(self, body):
9071
"""Export all users to a file using a long running job.
9172

auth0/v3/management/users.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,6 @@ def create(self, body):
116116
"""
117117
return self.client.post(self._url(), data=body)
118118

119-
def delete_all_users(self):
120-
"""Deletes all users (USE WITH CAUTION).
121-
Deprecation: This endpoint is no longer available server-side.
122-
123-
Args:
124-
"""
125-
warnings.warn(
126-
"DELETE all users endpoint is no longer available.", DeprecationWarning
127-
)
128-
return self.client.delete(self._url())
129-
130119
def get(self, id, fields=None, include_fields=True):
131120
"""Get a user.
132121

auth0/v3/test/authentication/test_database.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,6 @@
66

77

88
class TestDatabase(unittest.TestCase):
9-
@mock.patch("auth0.v3.rest.RestClient.post")
10-
def test_login(self, mock_post):
11-
d = Database("my.domain.com", "cid")
12-
13-
d.login(
14-
username="usrnm",
15-
password="pswd",
16-
id_token="idt",
17-
connection="conn",
18-
device="dev",
19-
grant_type="gt",
20-
scope="openid profile",
21-
)
22-
23-
args, kwargs = mock_post.call_args
24-
25-
self.assertEqual(args[0], "https://my.domain.com/oauth/ro")
26-
self.assertEqual(
27-
kwargs["data"],
28-
{
29-
"client_id": "cid",
30-
"username": "usrnm",
31-
"password": "pswd",
32-
"id_token": "idt",
33-
"connection": "conn",
34-
"device": "dev",
35-
"grant_type": "gt",
36-
"scope": "openid profile",
37-
},
38-
)
39-
409
@mock.patch("auth0.v3.rest.RestClient.post")
4110
def test_signup(self, mock_post):
4211
d = Database("my.domain.com", "cid")

auth0/v3/test/authentication/test_passwordless.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -104,47 +104,3 @@ def test_send_sms_with_client_secret(self, mock_post):
104104
"connection": "sms",
105105
},
106106
)
107-
108-
@mock.patch("auth0.v3.rest.RestClient.post")
109-
def test_send_sms_login(self, mock_post):
110-
111-
p = Passwordless("my.domain.com", "cid")
112-
113-
p.sms_login(phone_number="123456", code="abcd")
114-
115-
args, kwargs = mock_post.call_args
116-
117-
self.assertEqual(args[0], "https://my.domain.com/oauth/ro")
118-
self.assertEqual(
119-
kwargs["data"],
120-
{
121-
"client_id": "cid",
122-
"connection": "sms",
123-
"grant_type": "password",
124-
"username": "123456",
125-
"password": "abcd",
126-
"scope": "openid",
127-
},
128-
)
129-
130-
@mock.patch("auth0.v3.rest.RestClient.post")
131-
def test_send_sms_login_with_scope(self, mock_post):
132-
133-
p = Passwordless("my.domain.com", "cid")
134-
135-
p.sms_login(phone_number="123456", code="abcd", scope="openid profile")
136-
137-
args, kwargs = mock_post.call_args
138-
139-
self.assertEqual(args[0], "https://my.domain.com/oauth/ro")
140-
self.assertEqual(
141-
kwargs["data"],
142-
{
143-
"client_id": "cid",
144-
"connection": "sms",
145-
"grant_type": "password",
146-
"username": "123456",
147-
"password": "abcd",
148-
"scope": "openid profile",
149-
},
150-
)

auth0/v3/test/authentication/test_users.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,3 @@ def test_userinfo(self, mock_get):
1717
url="https://my.domain.com/userinfo",
1818
headers={"Authorization": "Bearer atk"},
1919
)
20-
21-
@mock.patch("auth0.v3.rest.RestClient.post")
22-
def test_tokeninfo(self, mock_post):
23-
24-
u = Users("my.domain.com")
25-
26-
u.tokeninfo(jwt="jwtoken")
27-
28-
mock_post.assert_called_with(
29-
url="https://my.domain.com/tokeninfo", data={"id_token": "jwtoken"}
30-
)

auth0/v3/test/management/test_jobs.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,6 @@ def test_get_failed_job(self, mock_rc):
3434
"https://domain/api/v2/jobs/an-id/errors",
3535
)
3636

37-
@mock.patch("auth0.v3.management.jobs.RestClient")
38-
def test_get_job_results(self, mock_rc):
39-
mock_instance = mock_rc.return_value
40-
41-
j = Jobs(domain="domain", token="jwttoken")
42-
j.get_results("an-id")
43-
44-
# Should use the 'get by id' URL
45-
mock_instance.get.assert_called_with(
46-
"https://domain/api/v2/jobs/an-id",
47-
)
48-
4937
@mock.patch("auth0.v3.management.jobs.RestClient")
5038
def test_export_users(self, mock_rc):
5139
mock_instance = mock_rc.return_value

auth0/v3/test/management/test_users.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,6 @@ def test_create(self, mock_rc):
7979
self.assertEqual("https://domain/api/v2/users", args[0])
8080
self.assertEqual(kwargs["data"], {"a": "b", "c": "d"})
8181

82-
@mock.patch("auth0.v3.management.users.RestClient")
83-
def test_delete_all_users(self, mock_rc):
84-
mock_instance = mock_rc.return_value
85-
86-
u = Users(domain="domain", token="jwttoken")
87-
u.delete_all_users()
88-
89-
mock_instance.delete.assert_called_with("https://domain/api/v2/users")
90-
9182
@mock.patch("auth0.v3.management.users.RestClient")
9283
def test_get(self, mock_rc):
9384
mock_instance = mock_rc.return_value

auth0/v3/test_async/test_async_token_verifier.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ async def test_async_asymmetric_verifier_fetches_key(self, mocked):
6969

7070
class TestAsyncJwksFetcher(unittest.IsolatedAsyncioTestCase):
7171
@aioresponses()
72-
async def test_async_get_jwks_json_twice_on_cache_expired(self, mocked):
73-
fetcher = AsyncJwksFetcher(JWKS_URI, cache_ttl=1)
72+
@unittest.mock.patch(
73+
"auth0.v3.authentication.token_verifier.time.time", return_value=0
74+
)
75+
async def test_async_get_jwks_json_twice_on_cache_expired(
76+
self, mocked, mocked_time
77+
):
78+
fetcher = AsyncJwksFetcher(JWKS_URI, cache_ttl=100)
7479

7580
callback, mock = get_callback(200, JWKS_RESPONSE_SINGLE_KEY)
7681
mocked.get(JWKS_URI, callback=callback)
@@ -89,7 +94,7 @@ async def test_async_get_jwks_json_twice_on_cache_expired(self, mocked):
8994
)
9095
self.assertEqual(mock.call_count, 1)
9196

92-
time.sleep(2)
97+
mocked_time.return_value = 200
9398

9499
# 2 seconds has passed, cache should be expired
95100
key_1 = await fetcher.get_key("test-key-1")

0 commit comments

Comments
 (0)