Skip to content

Commit

Permalink
Add a new env variable that uses the new granular permissions for Zoom.
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn committed Sep 18, 2024
1 parent d71ecef commit c9f3781
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion backend/src/appointment/controller/apis/zoom_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
import time

import sentry_sdk
Expand All @@ -14,6 +15,15 @@ class ZoomClient:
OAUTH_REQUEST_URL = 'https://api.zoom.us/v2'

SCOPES = ['user:read', 'user_info:read', 'meeting:write']
NEW_SCOPES = [
'meeting:read:meeting',
'meeting:write:meeting',
'meeting:update:meeting',
'meeting:delete:meeting',
'meeting:write:invite_links',
'user:read:email',
'user:read:user',
]

client: OAuth2Session | None = None
subscriber_id: int | None = None
Expand All @@ -24,6 +34,14 @@ def __init__(self, client_id, client_secret, callback_url):
self.callback_url = callback_url
self.subscriber_id = None
self.client = None
self.use_new_scopes = os.getenv('ZOOM_API_NEW_APP', False) == 'True'

@property
def scopes(self):
"""Returns the appropriate scopes"""
if self.use_new_scopes:
return self.NEW_SCOPES
return self.SCOPES

def check_expiry(self, token: dict | None):
"""Checks expires_at and if expired sets expires_in to a negative number to trigger refresh"""
Expand All @@ -50,7 +68,7 @@ def setup(self, subscriber_id=None, token=None):
self.client = OAuth2Session(
self.client_id,
redirect_uri=self.callback_url,
scope=self.SCOPES,
scope=self.scopes,
auto_refresh_url=self.OAUTH_TOKEN_URL,
auto_refresh_kwargs={
'client_id': self.client_id,
Expand Down

0 comments on commit c9f3781

Please sign in to comment.