【发布时间】:2015-04-20 20:34:47
【问题描述】:
gsutil 使用 boto configuration file 在 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 config 以在 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)。可能是任何已知格式 uri 用于访问 Google Drive 上的文件夹(没有存储桶或 Google Drive 的一些默认存储桶)?
【问题讨论】:
-
你解决过这个问题吗?
标签: authentication google-drive-api rsync gsutil