def zoom_auth(): """Endpoint to zoom oauth flow""" code = request.args.get("code") or "no code!" state = request.args.get("state") decoded_state = base64.b64decode(state).decode() team_id, _user_id = decoded_state.split(":") token_data: TokenData = ZoomOauthService.get_token_data(code) zoom = Zoom(token_data) DynamoUtils.save_zoom_data(team_id, zoom) return redirect( f"https://slack.com/app_redirect?app=A01H45TA509&team={team_id}", code=302)
def __get_access_token(self) -> str: """ Gets access token from self.token_data.access_token if not expired. If access_token is expired, refreshes and saves the new token data """ if ( self.zoom.token_data.expiry_date is not None and self.zoom.token_data.is_access_token_expired() is False ): return self.zoom.token_data.access_token else: if self.zoom.token_data.refresh_token is not None: logger.info("Token expired, refreshing...") self.zoom.token_data = ZoomOauthService.refresh_access_token( self.zoom.token_data ) DynamoUtils.save_zoom_data(self.team_id, self.zoom) logger.info("Token refreshed and saved") return self.zoom.token_data.access_token else: raise Exception()