41
41
class ClientContext (ClientRuntimeContext ):
42
42
"""SharePoint client context (SharePoint v1 API)"""
43
43
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
46
53
"""
47
54
Instantiates a SharePoint client context
48
55
@@ -51,7 +58,12 @@ def __init__(self, base_url, auth_context=None):
51
58
"""
52
59
super (ClientContext , self ).__init__ ()
53
60
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
+ )
55
67
self ._auth_context = auth_context
56
68
self ._web = None
57
69
self ._site = None
@@ -138,36 +150,18 @@ def with_access_token(self, token_func):
138
150
self .authentication_context .with_access_token (token_func )
139
151
return self
140
152
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
150
155
"""
151
156
Initializes a client to acquire a token via user credentials.
152
157
:param str username: Typically, a UPN in the form of an email address
153
158
: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'.
158
159
"""
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 ))
165
161
return self
166
162
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
171
165
"""
172
166
Initializes a client to acquire a token via client credentials (SharePoint App-Only)
173
167
@@ -176,25 +170,19 @@ def with_client_credentials(
176
170
177
171
:param str client_id: The OAuth client id of the calling application
178
172
: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'.
181
173
"""
182
174
self .authentication_context .with_credentials (
183
- ClientCredential (client_id , client_secret ), environment = environment
175
+ ClientCredential (client_id , client_secret )
184
176
)
185
177
return self
186
178
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
189
181
"""
190
182
Initializes a client to acquire a token via user or client credentials
191
183
:type credentials: UserCredential or ClientCredential
192
- :param str environment: The Office 365 Cloud Environment endpoint used for authentication
193
- defaults to 'commercial'.
194
184
"""
195
- self .authentication_context .with_credentials (
196
- credentials , environment = environment
197
- )
185
+ self .authentication_context .with_credentials (credentials )
198
186
return self
199
187
200
188
def execute_batch (self , items_per_batch = 100 , success_callback = None ):
0 commit comments