Skip to content

Commit 43db12a

Browse files
Dependency updates (msal msal), examples minor fixes, safe urlparse (compat)
1 parent 0e92b11 commit 43db12a

File tree

7 files changed

+34
-15
lines changed

7 files changed

+34
-15
lines changed

examples/requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
msal~=1.5.0
21
Faker~=4.1.2
32
adal~=1.2.4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import os
22
from office365.sharepoint.client_context import ClientContext
3-
from tests import settings
3+
from tests import test_site_url, test_tenant
44

55
cert_settings = {
66
'client_id': '51d03106-4726-442c-86db-70b32fa7547f',
77
'thumbprint': "6B36FBFC86FB1C019EB6496494B9195E6D179DDB",
88
'certificate_path': '{0}/selfsigncert.pem'.format(os.path.dirname(__file__))
99
}
1010

11-
ctx = ClientContext(settings.get('default', 'url')).with_client_certificate(settings.get('default', 'tenant'),
12-
cert_settings.get('client_id'),
13-
cert_settings.get('thumbprint'),
14-
cert_settings.get('certificate_path'))
11+
ctx = ClientContext(test_site_url).with_client_certificate(test_tenant,
12+
cert_settings.get('client_id'),
13+
cert_settings.get('thumbprint'),
14+
cert_settings.get('certificate_path'))
1515
current_web = ctx.web.get().execute_query()
1616
print("{0}".format(current_web.url))

office365/runtime/auth/providers/acs_token_provider.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import office365.logger
44
from office365.runtime.auth.authentication_provider import AuthenticationProvider
55
from office365.runtime.auth.token_response import TokenResponse
6+
from office365.runtime.compat import urlparse
67

78

89
class ACSTokenProvider(AuthenticationProvider, office365.logger.LoggerContext):
@@ -38,10 +39,6 @@ def ensure_app_only_access_token(self):
3839
def get_app_only_access_token(self):
3940
try:
4041
realm = self._get_realm_from_target_url()
41-
try:
42-
from urlparse import urlparse # Python 2.X
43-
except ImportError:
44-
from urllib.parse import urlparse # Python 3+
4542
url_info = urlparse(self.url)
4643
return self._get_app_only_access_token(url_info.hostname, realm)
4744
except requests.exceptions.RequestException as e:

office365/runtime/auth/sts_profile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
2-
from datetime import datetime, timezone, timedelta
3-
from urllib.parse import urlparse
2+
from datetime import datetime, timedelta
3+
from office365.runtime.compat import urlparse, timezone
44

55

66
class STSProfile(object):

office365/runtime/compat.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys
2+
3+
# -------
4+
# Pythons
5+
# -------
6+
7+
# Syntax sugar.
8+
_ver = sys.version_info
9+
10+
#: Python 2.x?
11+
is_py2 = (_ver[0] == 2)
12+
13+
#: Python 3.x?
14+
is_py3 = (_ver[0] == 3)
15+
16+
if is_py2:
17+
from urlparse import urlparse
18+
import pytz as timezone
19+
elif is_py3:
20+
from urllib.parse import urlparse
21+
from datetime import timezone
22+
23+

office365/sharepoint/folders/folder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from urllib.parse import urlparse
21
from office365.runtime.client_result import ClientResult
32
from office365.runtime.queries.create_entity_query import CreateEntityQuery
43
from office365.runtime.queries.service_operation_query import ServiceOperationQuery
@@ -16,6 +15,7 @@
1615
from office365.sharepoint.utilities.move_copy_options import MoveCopyOptions
1716
from office365.sharepoint.utilities.move_copy_util import MoveCopyUtil
1817
from office365.sharepoint.types.resource_path import ResourcePath as SPResPath
18+
from office365.runtime.compat import urlparse
1919

2020

2121
class Folder(BaseEntity):

requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
requests==2.25.1
22
requests_ntlm [NTLMAuthentication]
3-
setuptools==54.2.0
4-
msal==1.5.1
3+
setuptools==57.0.0
4+
msal==1.12.0
55
pytz==2021.1

0 commit comments

Comments
 (0)