iterative / PyDrive2

Google Drive API Python wrapper library. Maintained fork of PyDrive.
https://docs.iterative.ai/PyDrive2
Other
581 stars 69 forks source link

Predefined Login #174

Closed KeparYTbcc closed 2 years ago

KeparYTbcc commented 2 years ago

Hi, i wanted to do like somes AUTO BACKUP, but it ask for oauth each time, can't i just like predefine the acc i want, Like put the password + name in the script and avoid gettin the oauth page

KeparYTbcc commented 2 years ago

EX:


from pydrive2.auth import GoogleAuth
from pydrive2.drive import GoogleDrive

gauth = GoogleAuth("Email","password")
gauth.LocalWebserverAuth()

drive = GoogleDrive(gauth)
shcheklein commented 2 years ago

@KeparYTbcc try to create a settings.yaml file. Specifically, you would want to have:

save_credentials: True
save_credentials_backend: file
save_credentials_file: credentials.json

in it, if I understand your question right. Please feel free to reopen the ticket if you need more info.

KeparYTbcc commented 2 years ago

can i compile this "Settings.yaml" in pyinstaller?

KeparYTbcc commented 2 years ago

PS F:\bot-dev\csn\PROJECT LOLI> py loli.py
Traceback (most recent call last):
  File "F:\bot-dev\csn\PROJECT LOLI\loli.py", line 18, in <module>
    gauth.LocalWebserverAuth()       
  File "C:\Users\my-pc2\AppData\Local\Programs\Python\Python310\lib\site-packages\pydrive\auth.py", line 113, in _decorated
    self.GetFlow()
  File "C:\Users\my-pc2\AppData\Local\Programs\Python\Python310\lib\site-packages\pydrive\auth.py", line 443, in GetFlow
    self.LoadClientConfig()
  File "C:\Users\my-pc2\AppData\Local\Programs\Python\Python310\lib\site-packages\pydrive\auth.py", line 366, in LoadClientConfig    
    self.LoadClientConfigFile()
  File "C:\Users\my-pc2\AppData\Local\Programs\Python\Python310\lib\site-packages\pydrive\auth.py", line 384, in LoadClientConfigFile    client_config_file = self.settings['client_config_file']
KeyError: 'client_config_file'
Kolhax commented 2 years ago

@shcheklein

shcheklein commented 2 years ago

@Kolhax

It looks like you are using an older version of the lib, btw?

can i compile this "Settings.yaml" in pyinstaller?

I would do it this way then: https://github.com/iterative/dvc/blob/main/dvc/fs/gdrive.py#L224 - read the code around it. Basically it's overriding the default config values in the class to avoid creating the settings.yaml file. So everything is done in Python.

KeyError: 'client_config_file'

could you share the code that you are running please?

KeparYTbcc commented 2 years ago

the exact same as the guy send me earlier in the issue

@Kolhaxhttps://can01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKolhax&data=05%7C01%7C1583277%40cslaval.qc.ca%7C4612d3f50d8d46c8a25008da336f98ba%7C2c37d513624b457e92ac72faaeb34cba%7C0%7C0%7C637878851761491425%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=js%2FocMyn5xFsKPwZGWzG5Mj%2B6CIusnbYOG7gCt6F4gk%3D&reserved=0

It looks like you are using an older version of the lib, btw?

can i compile this "Settings.yaml" in pyinstaller?

I would do it this way then: https://github.com/iterative/dvc/blob/main/dvc/fs/gdrive.py#L224https://can01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fiterative%2Fdvc%2Fblob%2Fmain%2Fdvc%2Ffs%2Fgdrive.py%23L224&data=05%7C01%7C1583277%40cslaval.qc.ca%7C4612d3f50d8d46c8a25008da336f98ba%7C2c37d513624b457e92ac72faaeb34cba%7C0%7C0%7C637878851761491425%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=TQXBQ5aesFSSv8FELOgL4FrXgrnrbi4ygucs2v%2FHHqE%3D&reserved=0 - read the code around it. Basically it's overriding the default config values in the class to avoid creating the settings.yaml file. So everything is done in Python.

KeyError: 'client_config_file'

could you share the code that you are running please?

— Reply to this email directly, view it on GitHubhttps://can01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fiterative%2FPyDrive2%2Fissues%2F174%23issuecomment-1124020227&data=05%7C01%7C1583277%40cslaval.qc.ca%7C4612d3f50d8d46c8a25008da336f98ba%7C2c37d513624b457e92ac72faaeb34cba%7C0%7C0%7C637878851761491425%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=xXvUHPVppLTQgsjCEM%2F4QzgyyVkjy1ajrWXd9qyXvRc%3D&reserved=0, or unsubscribehttps://can01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAQGYT664K4ELJQHNVJZPUXTVJPROTANCNFSM5VTGHQFQ&data=05%7C01%7C1583277%40cslaval.qc.ca%7C4612d3f50d8d46c8a25008da336f98ba%7C2c37d513624b457e92ac72faaeb34cba%7C0%7C0%7C637878851761491425%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=goU5fmn9uE4wTHItSV7wHNBaVQ55GTYz61QYW43qCpw%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>