Skip to content

Commit 0f3f529

Browse files
author
Vadim
committed
fix: add session param and explicit verify=True to GraphClient and ClientContext with_transport
1 parent e926097 commit 0f3f529

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

office365/graph_client.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
from office365.teams.work import Teamwork
8080

8181
if TYPE_CHECKING:
82+
from requests import Session
8283
from office365.directory.applications.roles.collection import AppRoleCollection
8384
from office365.directory.applications.roles.role import AppRole
8485
from office365.directory.groups.setting import GroupSetting
@@ -173,10 +174,11 @@ def with_username_and_password(self, client_id: str, username: str, password: st
173174
def with_transport(
174175
self,
175176
proxies: dict[str, str] | None = None,
176-
verify: bool | str | None = None,
177+
verify: bool | str = True,
177178
timeout: int | tuple[int, int] | None = None,
179+
session: Session | None = None,
178180
) -> Self:
179-
"""Configure the HTTP transport (proxy, SSL, timeout).
181+
"""Configure the HTTP transport (proxy, SSL, timeout, custom session).
180182
181183
Note:
182184
MSAL authentication requests to ``login.microsoftonline.com`` use
@@ -187,11 +189,18 @@ def with_transport(
187189
proxies: Proxy URLs (e.g. ``{"https": "http://proxy:8080"}``)
188190
verify: SSL verification — ``True``, ``False``, or a CA bundle path
189191
timeout: Request timeout in seconds
192+
session: Custom ``requests.Session`` with pre-configured adapters
193+
(e.g. for NTLM/SSPI auth, custom TLS, connection pooling)
190194
191195
Returns:
192196
Self: Supports method chaining
193197
"""
194-
self.pending_request().with_transport(proxies=proxies, verify=verify, timeout=timeout)
198+
self.pending_request().with_transport(
199+
proxies=proxies,
200+
verify=verify,
201+
timeout=timeout,
202+
session=session,
203+
)
195204
return self
196205

197206
def execute_batch(

office365/sharepoint/client_context.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from office365.sharepoint.webs.web import Web
4343

4444
if TYPE_CHECKING:
45+
from requests import Session
4546
from office365.sharepoint.brandcenter.brand_center import BrandCenter
4647
from office365.sharepoint.portal.theme_manager import ThemeManager
4748
from office365.sharepoint.search.service import SearchService
@@ -167,10 +168,11 @@ def with_access_token(self, token_func: Callable[[], TokenResponse]) -> Self:
167168
def with_transport(
168169
self,
169170
proxies: dict[str, str] | None = None,
170-
verify: bool | str | None = None,
171+
verify: bool | str = True,
171172
timeout: int | tuple[int, int] | None = None,
173+
session: requests.Session | None = None,
172174
) -> Self:
173-
"""Configure the HTTP transport (proxy, SSL, timeout).
175+
"""Configure the HTTP transport (proxy, SSL, timeout, custom session).
174176
175177
Note:
176178
MSAL authentication requests to ``login.microsoftonline.com`` use
@@ -181,11 +183,18 @@ def with_transport(
181183
proxies: Proxy URLs (e.g. ``{"https": "http://proxy:8080"}``)
182184
verify: SSL verification — ``True``, ``False``, or a CA bundle path
183185
timeout: Request timeout in seconds
186+
session: Custom ``requests.Session`` with pre-configured adapters
187+
(e.g. for NTLM/SSPI auth, custom TLS, connection pooling)
184188
185189
Returns:
186190
Self: Supports method chaining
187191
"""
188-
self.pending_request().with_transport(proxies=proxies, verify=verify, timeout=timeout)
192+
self.pending_request().with_transport(
193+
proxies=proxies,
194+
verify=verify,
195+
timeout=timeout,
196+
session=session,
197+
)
189198
return self
190199

191200
def with_user_credentials(self, username: str, password: str) -> Self:

0 commit comments

Comments
 (0)