Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions backend/python/app/sources/client/box/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ class BoxRESTClientViaToken:
"""Box client via Developer Token or OAuth2 access token."""
def __init__(self, access_token: str) -> None:
self.access_token = access_token
self._auth = BoxDeveloperTokenAuth(token=self.access_token)
self.box_client = None

async def create_client(self) -> BoxSDKClient: # type: ignore[valid-type]
"""Create Box client using Developer Token or OAuth2 token."""
auth = BoxDeveloperTokenAuth(token=self.access_token)
self.box_client = BoxSDKClient(auth=auth)
# Reuse initialized auth object for efficiency
# Only re-instantiate client when necessary
if self.box_client is None:
self.box_client = BoxSDKClient(auth=self._auth)
return self.box_client

def get_box_client(self) -> BoxSDKClient: # type: ignore[valid-type]
Expand Down