Skip to content

Commit

Permalink
Support authenticating with refresh token and app key
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Sep 6, 2024
1 parent c4dc46c commit b863f77
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions dropboxdrivefs/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
from typing import Optional

import dropbox.files
import requests
from dropbox.exceptions import ApiError
Expand Down Expand Up @@ -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.")

Expand Down

0 comments on commit b863f77

Please sign in to comment.