@@ -230,3 +230,66 @@ def single_request_timeout(self):
230
230
def wait_on_rate_limit (self ):
231
231
"""Automatic rate-limit handling enabled / disabled."""
232
232
return self ._session .wait_on_rate_limit
233
+
234
+ # Create a class attribute for the Access Tokens API that can be accessed
235
+ # before WebexTeamsAPI object is initialized.
236
+ access_tokens = AccessTokensAPI (
237
+ base_url = DEFAULT_BASE_URL ,
238
+ object_factory = immutable_data_factory ,
239
+ single_request_timeout = DEFAULT_SINGLE_REQUEST_TIMEOUT ,
240
+ )
241
+
242
+ @classmethod
243
+ def from_oauth_code (cls , client_id , client_secret , code , redirect_uri ):
244
+ """Create a new WebexTeamsAPI connection object using an OAuth code.
245
+
246
+ Exchange an Authorization Code for an Access Token, then use the access
247
+ token to create a new WebexTeamsAPI connection object.
248
+
249
+ Args:
250
+ client_id(basestring): Provided when you created your integration.
251
+ client_secret(basestring): Provided when you created your
252
+ integration.
253
+ code(basestring): The Authorization Code provided by the user
254
+ OAuth process.
255
+ redirect_uri(basestring): The redirect URI used in the user OAuth
256
+ process.
257
+
258
+ Returns:
259
+ AccessToken: An AccessToken object with the access token provided
260
+ by the Webex Teams cloud.
261
+
262
+ Raises:
263
+ TypeError: If the parameter types are incorrect.
264
+ ApiError: If the Webex Teams cloud returns an error.
265
+ """
266
+ token_obj = cls .access_tokens .get (client_id , client_secret , code ,
267
+ redirect_uri )
268
+
269
+ return cls (access_token = token_obj .access_token )
270
+
271
+ @classmethod
272
+ def from_oauth_refresh (cls , client_id , client_secret , refresh_token ):
273
+ """Create a new WebexTeamsAPI connection object using an OAuth refresh.
274
+
275
+ Exchange a refresh token for an Access Token, then use the access
276
+ token to create a new WebexTeamsAPI connection object.
277
+
278
+ Args:
279
+ client_id(basestring): Provided when you created your integration.
280
+ client_secret(basestring): Provided when you created your
281
+ integration.
282
+ refresh_token(basestring): Provided when you requested the Access
283
+ Token.
284
+
285
+ Returns:
286
+ AccessToken: With the access token provided by the Webex Teams
287
+ cloud.
288
+
289
+ Raises:
290
+ TypeError: If the parameter types are incorrect.
291
+ ApiError: If the Webex Teams cloud returns an error.
292
+ """
293
+ token_obj = cls .access_tokens .refresh (client_id , client_secret ,
294
+ refresh_token )
295
+ return cls (access_token = token_obj .access_token )
0 commit comments