Skip to content

Commit

Permalink
Merge pull request #33 from minds-ai/fix_zoom_download
Browse files Browse the repository at this point in the history
Switch back to JWT token for downloads
  • Loading branch information
jbedorf committed Jun 29, 2021
2 parents a8d77b9 + 839a74d commit ba62e0b
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions zoom_drive_connector/zoom/zoom_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,29 @@ def download_recording(self, url: str, auth: bytes) -> str:
:param auth: Encoded JWT authorization token
:return: Path to the recording
"""

# Generate a zak token, required for direct download
zoom_url = str(ZoomURLS.zak_token.value).format(user=self.zoom_config.username)
try:
zoom_request = requests.get(zoom_url, params={'access_token': auth})
except requests.exceptions.RequestException as e:
log.log(logging.ERROR, e)
raise ZoomAPIException(404, 'File Not Found', None, 'Could not connect')

status_code = zoom_request.status_code
if 200 <= status_code <= 299:
log.log(logging.DEBUG, zoom_request.json())
elif 300 <= status_code <= 599:
raise ZoomAPIException(status_code, zoom_request.reason, zoom_request.request,
self.message.get(status_code, ''))
else:
raise ZoomAPIException(status_code, zoom_request.reason, zoom_request.request, '')
# zoom_url = str(ZoomURLS.zak_token.value).format(user=self.zoom_config.username)
# try:
# zoom_request = requests.get(zoom_url, params={'access_token': auth})
# except requests.exceptions.RequestException as e:
# log.log(logging.ERROR, e)
# raise ZoomAPIException(404, 'File Not Found', None, 'Could not connect')

# status_code = zoom_request.status_code
# if 200 <= status_code <= 299:
# log.log(logging.DEBUG, zoom_request.json())
# elif 300 <= status_code <= 599:
# raise ZoomAPIException(status_code, zoom_request.reason, zoom_request.request,
# self.message.get(status_code, ''))
# else:
# raise ZoomAPIException(status_code, zoom_request.reason, zoom_request.request, '')

# Use the zak token in order to download the file
zoom_request = requests.get(url + "?zak=" + zoom_request.json()['token'], stream=True)
# zoom_request = requests.get(url + "?zak=" + zoom_request.json()['token'], stream=True)
# June 29, 2021. Zak token downloads started failing, switching back to default JWT token
zoom_request = requests.get(url, stream=True, params={'access_token': auth})


filename = url.split('/')[-1]
outfile = os.path.join(str(self.sys_config.target_folder), filename + '.mp4')
with open(outfile, 'wb') as source:
Expand Down

0 comments on commit ba62e0b

Please sign in to comment.