gsutil https://cloud.google.com/storage/docs/gsutil?csw=1#gettingstarted use 博托配置文件 https://cloud.google.com/storage/docs/gsutil_install#config用于在 Google Cloud Storage 进行身份验证。
我在 console.developers.google.com 中生成 ClientID - 允许通过 python 脚本将文件放入 Google Drive:
#!/usr/bin/env python
from apiclient.discovery import build
from apiclient.http import MediaFileUpload
import httplib2
from oauth2client.client import SignedJwtAssertionCredentials
credentials = SignedJwtAssertionCredentials(
service_account_name='301714561983-nkd8kalz1op3bdjn75ija1b7ef1sslpr@developer.gserviceaccount.com',
private_key='''-----BEGIN PRIVATE KEY-----
приватный ключик
-----END PRIVATE KEY-----''',
scope = [
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.file',
'https://www.googleapis.com/auth/drive.appdata',
'https://www.googleapis.com/auth/drive.apps.readonly'
]
)
http = httplib2.Http()
http = credentials.authorize(http)
drive_folder_id = '0C3ZU6kySEIuCT0ANM3RRVE1iME0' #folder id
service = build('drive', 'v2', http=http)
media_body = MediaFileUpload('document.txt')
body = {
'title': 'document.txt',
'description': 'backup',
'mimeType': 'text/plain',
'parents': [{'id': drive_folder_id}]
}
file = service.files().insert(
body=body,
media_body=media_body).execute()
我想用gsutil rsync用于将我的数据与 Google 云端硬盘同步。
有人知道如何配置 boto 配置以在 Google Drive 进行身份验证吗?如果可能的话,该怎么做?
目前我使用 ClientID (gsutil config -e) 来发现对谷歌云存储的访问:
$ gsutil ls gs://uspto-pair/applications/0800401*
gs://uspto-pair/applications/08004010.zip
gs://uspto-pair/applications/08004011.zip
gs://uspto-pair/applications/08004012.zip
gs://uspto-pair/applications/08004013.zip
gs://uspto-pair/applications/08004016.zip
gs://uspto-pair/applications/08004017.zip
gs://uspto-pair/applications/08004019.zip
但我无法访问文件夹(通过路径或文件夹 ID)。可能有人知道用于访问 Google Drive 上的文件夹的 uri 格式(没有存储桶或使用 Google Drive 的某些默认存储桶)?