@@ -81,7 +81,7 @@ def with_client_certificate(
81
81
thumbprint ,
82
82
cert_path = None ,
83
83
private_key = None ,
84
- scopes = None ,
84
+ scopes = None
85
85
):
86
86
# type: (str, str, str, Optional[str], Optional[str], Optional[List[str]]) -> Self
87
87
"""
@@ -93,7 +93,6 @@ def with_client_certificate(
93
93
:param str thumbprint: Hex encoded thumbprint of the certificate.
94
94
:param str client_id: The OAuth client id of the calling application.
95
95
:param list[str] or None scopes: Scopes requested to access a protected API (a resource)
96
-
97
96
"""
98
97
self .authentication_context .with_client_certificate (
99
98
tenant , client_id , thumbprint , cert_path , private_key , scopes
@@ -139,15 +138,15 @@ def with_access_token(self, token_func):
139
138
def with_user_credentials (
140
139
self , username , password , allow_ntlm = False , browser_mode = False , environment = 'commercial'
141
140
):
142
- # type: (str, str, bool, bool, str) -> Self
141
+ # type: (str, str, bool, bool, Optional[ str] ) -> Self
143
142
"""
144
143
Initializes a client to acquire a token via user credentials.
145
144
:param str username: Typically, a UPN in the form of an email address
146
145
:param str password: The password
147
146
:param bool allow_ntlm: Flag indicates whether NTLM scheme is enabled. Disabled by default
148
147
:param bool browser_mode:
149
- :param str environment: The Office 365 Cloud Environment endpoint used for authentication.
150
- By default, this will be set to commercial ( 'commercial', 'GCCH')
148
+ :param str environment: The Office 365 Cloud Environment endpoint used for authentication
149
+ defaults to 'commercial'.
151
150
"""
152
151
self .authentication_context .with_credentials (
153
152
UserCredential (username , password ),
@@ -157,8 +156,8 @@ def with_user_credentials(
157
156
)
158
157
return self
159
158
160
- def with_client_credentials (self , client_id , client_secret ):
161
- # type: (str, str) -> Self
159
+ def with_client_credentials (self , client_id , client_secret , environment = 'commercial' ):
160
+ # type: (str, str, Optional[str] ) -> Self
162
161
"""
163
162
Initializes a client to acquire a token via client credentials (SharePoint App-Only)
164
163
@@ -167,19 +166,24 @@ def with_client_credentials(self, client_id, client_secret):
167
166
168
167
:param str client_id: The OAuth client id of the calling application
169
168
:param str client_secret: Secret string that the application uses to prove its identity when requesting a token
169
+ :param str environment: The Office 365 Cloud Environment endpoint used for authentication
170
+ defaults to 'commercial'.
170
171
"""
171
172
self .authentication_context .with_credentials (
172
- ClientCredential (client_id , client_secret )
173
+ ClientCredential (client_id , client_secret ),
174
+ environment = environment
173
175
)
174
176
return self
175
177
176
- def with_credentials (self , credentials ):
177
- # type: (UserCredential|ClientCredential) -> Self
178
+ def with_credentials (self , credentials , environment = 'commercial' ):
179
+ # type: (UserCredential|ClientCredential, Optional[str] ) -> Self
178
180
"""
179
181
Initializes a client to acquire a token via user or client credentials
180
182
:type credentials: UserCredential or ClientCredential
183
+ :param str environment: The Office 365 Cloud Environment endpoint used for authentication
184
+ defaults to 'commercial'.
181
185
"""
182
- self .authentication_context .with_credentials (credentials )
186
+ self .authentication_context .with_credentials (credentials , environment = environment )
183
187
return self
184
188
185
189
def execute_batch (self , items_per_batch = 100 , success_callback = None ):
0 commit comments