|
32 | 32 | from webexteamssdk.exceptions import AccessTokenError
|
33 | 33 | from webexteamssdk.models.immutable import immutable_data_factory
|
34 | 34 | from webexteamssdk.restsession import RestSession
|
35 |
| -from webexteamssdk.utils import check_type, check_all_not_none |
| 35 | +from webexteamssdk.utils import check_type |
36 | 36 | from .access_tokens import AccessTokensAPI
|
37 | 37 | from .events import EventsAPI
|
| 38 | +from .guest_issuer import GuestIssuerAPI |
38 | 39 | from .licenses import LicensesAPI
|
39 | 40 | from .memberships import MembershipsAPI
|
40 | 41 | from .messages import MessagesAPI
|
|
45 | 46 | from .team_memberships import TeamMembershipsAPI
|
46 | 47 | from .teams import TeamsAPI
|
47 | 48 | from .webhooks import WebhooksAPI
|
48 |
| -from .guest_issuer import GuestIssuerAPI |
49 | 49 |
|
50 | 50 |
|
51 | 51 | class WebexTeamsAPI(object):
|
@@ -129,19 +129,24 @@ def __init__(self, access_token=None, base_url=DEFAULT_BASE_URL,
|
129 | 129 |
|
130 | 130 | access_token = access_token or WEBEX_TEAMS_ACCESS_TOKEN
|
131 | 131 |
|
132 |
| - # Check if the user has provided the required oauth parameters |
133 |
| - oauth_param_list = [client_id, client_secret, oauth_code, redirect_uri] |
134 |
| - # Init AccessTokensAPI earlier to use for oauth requests |
| 132 | + # Init AccessTokensAPI wrapper early to use for oauth requests |
135 | 133 | self.access_tokens = AccessTokensAPI(
|
136 | 134 | self.base_url, object_factory,
|
137 | 135 | single_request_timeout=single_request_timeout
|
138 | 136 | )
|
139 |
| - if not access_token and check_all_not_none(oauth_param_list): |
140 |
| - access_token = self.access_tokens.get(client_id=client_id, |
141 |
| - client_secret=client_secret, |
142 |
| - code=oauth_code, |
143 |
| - redirect_uri=redirect_uri |
144 |
| - ).access_token |
| 137 | + |
| 138 | + # Check if the user has provided the required oauth parameters |
| 139 | + oauth_param_list = [client_id, client_secret, oauth_code, redirect_uri] |
| 140 | + if not access_token and all(oauth_param_list): |
| 141 | + access_token = self.access_tokens.get( |
| 142 | + client_id=client_id, |
| 143 | + client_secret=client_secret, |
| 144 | + code=oauth_code, |
| 145 | + redirect_uri=redirect_uri |
| 146 | + ).access_token |
| 147 | + |
| 148 | + # If an access token hasn't been provided as a parameter, environment |
| 149 | + # variable, or obtained via an OAuth exchange raise an error. |
145 | 150 | if not access_token:
|
146 | 151 | raise AccessTokenError(
|
147 | 152 | "You must provide a Webex Teams access token to interact with "
|
|
0 commit comments