From b863f77d9b5763a1dcb389eef518ba381ec518d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Thu, 5 Sep 2024 19:53:45 -0600 Subject: [PATCH] Support authenticating with refresh token and app key --- dropboxdrivefs/core.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/dropboxdrivefs/core.py b/dropboxdrivefs/core.py index 5e8ba58..23cfe00 100644 --- a/dropboxdrivefs/core.py +++ b/dropboxdrivefs/core.py @@ -1,4 +1,6 @@ import logging +from typing import Optional + import dropbox.files import requests from dropbox.exceptions import ApiError @@ -48,11 +50,22 @@ def _call(self, _, method="get", path=None, data=None, redirect=True, offset=0, out.raise_for_status() return out - def connect(self, token=None, client=None): + def connect( + self, + token: Optional[str] = None, + client: Optional[dropbox.Dropbox] = None, + *, + app_key: Optional[str], + refresh_token: Optional[str] = None, + ): if client is not None: self.dbx = client elif token is not None: - self.dbx = dropbox.Dropbox(token) + self.dbx = dropbox.Dropbox( + token, + oauth2_refresh_token=refresh_token, + app_key=app_key, + ) else: raise ValueError("You must provide either a token or a dropbox client object.")