4141class ClientContext (ClientRuntimeContext ):
4242 """SharePoint client context (SharePoint v1 API)"""
4343
44- def __init__ (self , base_url , auth_context = None ):
45- # type: (str, AuthenticationContext | None) -> None
44+ def __init__ (
45+ self ,
46+ base_url ,
47+ auth_context = None ,
48+ environment = "commercial" ,
49+ allow_ntlm = False ,
50+ browser_mode = False ,
51+ ):
52+ # type: (str, Optional[AuthenticationContext], str, bool, bool) -> None
4653 """
4754 Instantiates a SharePoint client context
4855
@@ -51,7 +58,12 @@ def __init__(self, base_url, auth_context=None):
5158 """
5259 super (ClientContext , self ).__init__ ()
5360 if auth_context is None :
54- auth_context = AuthenticationContext (url = base_url )
61+ auth_context = AuthenticationContext (
62+ url = base_url ,
63+ environment = environment ,
64+ allow_ntlm = allow_ntlm ,
65+ browser_mode = browser_mode ,
66+ )
5567 self ._auth_context = auth_context
5668 self ._web = None
5769 self ._site = None
@@ -138,36 +150,18 @@ def with_access_token(self, token_func):
138150 self .authentication_context .with_access_token (token_func )
139151 return self
140152
141- def with_user_credentials (
142- self ,
143- username ,
144- password ,
145- allow_ntlm = False ,
146- browser_mode = False ,
147- environment = "commercial" ,
148- ):
149- # type: (str, str, bool, bool, Optional[str]) -> Self
153+ def with_user_credentials (self , username , password ):
154+ # type: (str, str) -> Self
150155 """
151156 Initializes a client to acquire a token via user credentials.
152157 :param str username: Typically, a UPN in the form of an email address
153158 :param str password: The password
154- :param bool allow_ntlm: Flag indicates whether NTLM scheme is enabled. Disabled by default
155- :param bool browser_mode:
156- :param str environment: The Office 365 Cloud Environment endpoint used for authentication
157- defaults to 'commercial'.
158159 """
159- self .authentication_context .with_credentials (
160- UserCredential (username , password ),
161- allow_ntlm = allow_ntlm ,
162- browser_mode = browser_mode ,
163- environment = environment ,
164- )
160+ self .authentication_context .with_credentials (UserCredential (username , password ))
165161 return self
166162
167- def with_client_credentials (
168- self , client_id , client_secret , environment = "commercial"
169- ):
170- # type: (str, str, Optional[str]) -> Self
163+ def with_client_credentials (self , client_id , client_secret ):
164+ # type: (str, str) -> Self
171165 """
172166 Initializes a client to acquire a token via client credentials (SharePoint App-Only)
173167
@@ -176,25 +170,19 @@ def with_client_credentials(
176170
177171 :param str client_id: The OAuth client id of the calling application
178172 :param str client_secret: Secret string that the application uses to prove its identity when requesting a token
179- :param str environment: The Office 365 Cloud Environment endpoint used for authentication
180- defaults to 'commercial'.
181173 """
182174 self .authentication_context .with_credentials (
183- ClientCredential (client_id , client_secret ), environment = environment
175+ ClientCredential (client_id , client_secret )
184176 )
185177 return self
186178
187- def with_credentials (self , credentials , environment = "commercial" ):
188- # type: (UserCredential|ClientCredential, Optional[str] ) -> Self
179+ def with_credentials (self , credentials ):
180+ # type: (UserCredential|ClientCredential) -> Self
189181 """
190182 Initializes a client to acquire a token via user or client credentials
191183 :type credentials: UserCredential or ClientCredential
192- :param str environment: The Office 365 Cloud Environment endpoint used for authentication
193- defaults to 'commercial'.
194184 """
195- self .authentication_context .with_credentials (
196- credentials , environment = environment
197- )
185+ self .authentication_context .with_credentials (credentials )
198186 return self
199187
200188 def execute_batch (self , items_per_batch = 100 , success_callback = None ):
0 commit comments