我有以下代码:
from pydrive.auth import GoogleAuth
gauth = GoogleAuth()
gauth.DEFAULT_SETTINGS = {'save_credentials': True,'client_config_backend': 'settings',
'oauth_scope': ['https://www.googleapis.com/auth/drive'],
'get_refresh_token': True,
'save_credentials_file':"credential_log.txt",
'save_credentials_backend': 'file'}
gauth.client_config = {'client_id': '499039293801-krogpnentl6qk035vt4hcd36nefiautt.apps.googleusercontent.com', 'client_secret': 'iqFCuOh36amMFi3U1dkyCWJK',
'redirect_uri':'urn:ietf:wg:oauth:2.0:oob','revoke_uri': 'None',
'token_uri':'https://accounts.google.com/o/oauth2/token',
'auth_uri':'https://accounts.google.com/o/oauth2/auth',
'save_credentials_file':"mycreds_p2iman.txt"}
gauth.CommandLineAuth()
from pydrive.drive import GoogleDrive
drive = GoogleDrive(gauth)
file4 = drive.CreateFile({'title':'somethingdifferent.txt', 'mimeType':'different/txt'})
file4.SetContentString('My name is John')
file4.Upload() # Upload file.
file4.SetContentString('My name is John')
file4.Upload() # Update content of the file.
问题是在谷歌浏览器中生成了一个验证码,每次用户需要复制->将其粘贴到控制台中以进行身份验证。有没有办法自动化这个过程?