如何使用Python上传到Google Drive而无需身份验证?

11 浏览
0 Comments

如何使用Python上传到Google Drive而无需身份验证?

我想使用Google Script和Python将文件上传到Google Drive。

我不想使用API,因为它需要JSON文件,并要求输入Google账户的密码。

我想从Python文件中直接发送,不需要JSON文件,也不需要输入Google账户。

我想在Google Script中创建一个脚本,将文件上传到网站。

我找到了如何使用HTML实现:

function saveFile(data,name,folderName) { 
   var contentType = data.substring(5,data.indexOf(';'));
   var file = Utilities.newBlob(
     Utilities.base64Decode(data.substr(data.indexOf('base64,')+7)), 
     contentType, 
     name
   ); //does the uploading of the files
   DriveApp.getFolderById(childFolderIdA).createFile(file);
}

但是我没有找到如何使用Python实现。

如何将文件发送到这段代码中?

0