从字符串凭证进行python pydrive身份验证

时间:2019-03-03 22:06:45

标签: python string cloud pydrive

当前,我一直在使用以下脚本对Google云平台进行身份验证:

gauth = GoogleAuth()
# Try to load saved client credentials
gauth.LoadCredentialsFile("mycreds.txt")
if gauth.credentials is None:
    # Authenticate if they're not there
    gauth.LocalWebserverAuth()
elif gauth.access_token_expired:
    # Refresh them if expired
    gauth.Refresh()
else:
    # Initialize the saved creds
    gauth.Authorize()
# Save the current credentials to a file
gauth.SaveCredentialsFile("mycreds.txt")
drive = GoogleDrive(gauth)
textfile = drive.CreateFile({'title': str(filename_base+xdate+filename_ext)})
# job_titles = [line.decode('utf-8').strip() for line in references]
textfile.SetContentString(str(references))
textfile.Upload()

但是,最近,我不得不从用户的角度隐藏mycreds.txt文件。文档中没有称为LoadCredentialsString的方法,所以我的问题是是否可以绕过LoadCredentialsFile函数作为真正长字符串作为参数传递?

感谢您的答复。

0 个答案:

没有答案