@@ -81,7 +81,7 @@ def with_client_certificate(
8181 thumbprint ,
8282 cert_path = None ,
8383 private_key = None ,
84- scopes = None ,
84+ scopes = None
8585 ):
8686 # type: (str, str, str, Optional[str], Optional[str], Optional[List[str]]) -> Self
8787 """
@@ -93,7 +93,6 @@ def with_client_certificate(
9393 :param str thumbprint: Hex encoded thumbprint of the certificate.
9494 :param str client_id: The OAuth client id of the calling application.
9595 :param list[str] or None scopes: Scopes requested to access a protected API (a resource)
96-
9796 """
9897 self .authentication_context .with_client_certificate (
9998 tenant , client_id , thumbprint , cert_path , private_key , scopes
@@ -139,15 +138,15 @@ def with_access_token(self, token_func):
139138 def with_user_credentials (
140139 self , username , password , allow_ntlm = False , browser_mode = False , environment = 'commercial'
141140 ):
142- # type: (str, str, bool, bool, str) -> Self
141+ # type: (str, str, bool, bool, Optional[ str] ) -> Self
143142 """
144143 Initializes a client to acquire a token via user credentials.
145144 :param str username: Typically, a UPN in the form of an email address
146145 :param str password: The password
147146 :param bool allow_ntlm: Flag indicates whether NTLM scheme is enabled. Disabled by default
148147 :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'.
151150 """
152151 self .authentication_context .with_credentials (
153152 UserCredential (username , password ),
@@ -157,8 +156,8 @@ def with_user_credentials(
157156 )
158157 return self
159158
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
162161 """
163162 Initializes a client to acquire a token via client credentials (SharePoint App-Only)
164163
@@ -167,19 +166,24 @@ def with_client_credentials(self, client_id, client_secret):
167166
168167 :param str client_id: The OAuth client id of the calling application
169168 :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'.
170171 """
171172 self .authentication_context .with_credentials (
172- ClientCredential (client_id , client_secret )
173+ ClientCredential (client_id , client_secret ),
174+ environment = environment
173175 )
174176 return self
175177
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
178180 """
179181 Initializes a client to acquire a token via user or client credentials
180182 :type credentials: UserCredential or ClientCredential
183+ :param str environment: The Office 365 Cloud Environment endpoint used for authentication
184+ defaults to 'commercial'.
181185 """
182- self .authentication_context .with_credentials (credentials )
186+ self .authentication_context .with_credentials (credentials , environment = environment )
183187 return self
184188
185189 def execute_batch (self , items_per_batch = 100 , success_callback = None ):
0 commit comments