小编RNZ*_*RNZ的帖子

将 gsutil 与谷歌驱动器(不是谷歌云存储)一起使用

gsutil使用boto 配置文件在 Google Cloud Storage 进行身份验证。

\n\n

我在 console.developers.google.com 中生成 ClientID - 允许通过 python 脚本将文件放入 Google Drive:

\n\n
#!/usr/bin/env python\n\nfrom apiclient.discovery import build\nfrom apiclient.http import MediaFileUpload\nimport httplib2\nfrom oauth2client.client import SignedJwtAssertionCredentials\n\ncredentials = SignedJwtAssertionCredentials(\nservice_account_name=\'301714561983-nkd8kalz1op3bdjn75ija1b7ef1sslpr@developer.gserviceaccount.com\',\nprivate_key=\'\'\'-----BEGIN PRIVATE KEY-----\n\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb0\xd1\x82\xd0\xbd\xd1\x8b\xd0\xb9 \xd0\xba\xd0\xbb\xd1\x8e\xd1\x87\xd0\xb8\xd0\xba \n-----END PRIVATE KEY-----\'\'\',\n        scope = [\n                \'https://www.googleapis.com/auth/drive\',\n                \'https://www.googleapis.com/auth/drive.file\',\n                \'https://www.googleapis.com/auth/drive.appdata\',\n                \'https://www.googleapis.com/auth/drive.apps.readonly\'\n        ]\n)\n\nhttp = httplib2.Http()\nhttp = credentials.authorize(http)\n\ndrive_folder_id = \'0C3ZU6kySEIuCT0ANM3RRVE1iME0\' #folder id\n\nservice = build(\'drive\', \'v2\', http=http)\n\nmedia_body = MediaFileUpload(\'document.txt\')\nbody = {\n        \'title\': \'document.txt\',\n        \'description\': \'backup\',\n        \'mimeType\': \'text/plain\',\n        \'parents\': [{\'id\': drive_folder_id}]\n}\n\nfile = service.files().insert(\n        body=body,\n        media_body=media_body).execute()\n
Run Code Online (Sandbox Code Playgroud)\n\n

我想使用 …

authentication rsync google-drive-api gsutil

6
推荐指数
1
解决办法
7802
查看次数

标签 统计

authentication ×1

google-drive-api ×1

gsutil ×1

rsync ×1