RNZ*_*RNZ 6 authentication rsync google-drive-api 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我想使用gsutil rsync将我的数据与 Google Drive 同步。\n有人知道如何配置 boto 配置以在 Google 云端硬盘上进行身份验证吗?如果可能的话,该怎么做?
\n\n目前我使用 ClientID (gsutil config -e) 来发现对谷歌云存储的访问:
\n\n$ gsutil ls gs://uspto-pair/applications/0800401*\ngs://uspto-pair/applications/08004010.zip\ngs://uspto-pair/applications/08004011.zip\ngs://uspto-pair/applications/08004012.zip\ngs://uspto-pair/applications/08004013.zip\ngs://uspto-pair/applications/08004016.zip\ngs://uspto-pair/applications/08004017.zip\ngs://uspto-pair/applications/08004019.zip\n
Run Code Online (Sandbox Code Playgroud)\n\n但我无法访问文件夹(通过路径或文件夹 ID)。可能有人知道用于访问 Google Drive 上的文件夹的 uri 格式(没有存储桶或使用 Google Drive 的某些默认存储桶)?
\n 归档时间: |
|
查看次数: |
7802 次 |
最近记录: |