Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pvk-developer
Copy link
Member

Resolves #2238
This pr changes the usage of pydrive to official google api calls without the need of third party libraries like PyDrive2 or the currently deprecated PyDrive.

CU-86b29t2nz

@sdv-team
Copy link
Contributor

sdv-team commented Oct 4, 2024

@pvk-developer pvk-developer marked this pull request as ready for review October 4, 2024 12:50
@pvk-developer pvk-developer requested a review from a team as a code owner October 4, 2024 12:50
@pvk-developer pvk-developer requested review from rwedge and removed request for a team October 4, 2024 12:50
@@ -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',
Copy link
Contributor

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

Comment on lines +32 to +33
credentials = json.loads(tmp_credentials)
creds = Credentials.from_authorized_user_info(credentials, SCOPES)
Copy link
Contributor

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():
Copy link
Contributor

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()
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Contributor

@amontanez24 amontanez24 left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use PyDrive2 instead of PyDrive
3 participants