-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the code related to pydrive
and use google-api
instead
#2254
base: main
Are you sure you want to change the base?
Change the code related to pydrive
and use google-api
instead
#2254
Conversation
@@ -62,7 +62,11 @@ test = [ | |||
'rundoc>=0.4.3,<0.5', | |||
'pytest-runner >= 2.11.1', | |||
'tomli>=2.0.0,<3', | |||
'pydrive', | |||
'google-api-python-client', | |||
'google-auth', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this and google-auth-httplib2 already seem to be required by the python client
credentials = json.loads(tmp_credentials) | ||
creds = Credentials.from_authorized_user_info(credentials, SCOPES) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: maybe we rename the first one to credentials_json and the other to credentials or something
@@ -25,53 +26,38 @@ def _generate_filename(): | |||
|
|||
|
|||
def _get_drive_client(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: should we rename to _get_drive_service?
xlsx_mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' | ||
drive_file.FetchContent(mimetype=xlsx_mime) | ||
return pd.read_excel(drive_file.content, sheet_name=None) | ||
service = _get_drive_client() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we be calling service.close()
when we're done with it?
if creds and creds.expired and creds.refresh_token: | ||
creds.refresh(Request()) | ||
else: | ||
flow = InstalledAppFlow.from_client_secrets_file('client_secrets.json', SCOPES) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file doesn't exist does it? Will this block ever work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry this was from my local. I will remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can simplify the authentication section. We never authenticate by loading from a json file on the user's machine so I don't think we need that option. We can either just refresh the credentials like we do or use InstalledAppFlow.from_client_config and just load from the string
Resolves #2238
This
pr
changes the usage ofpydrive
to officialgoogle
api calls without the need of third party libraries likePyDrive2
or the currently deprecatedPyDrive
.CU-86b29t2nz