【发布时间】:2016-04-25 10:25:40
【问题描述】:
假设我在项目 X 中有谷歌云存储桶,并且想要从部署在项目 Y 上的代码(Python)上传项目 X 中的桶中的对象。 项目 X 和 Y 都使用相同的凭据(登录 ID)。
是否可以使用 OAuth2.0 或任何其他建议来实现? 我曾尝试使用 Service Account、AppAssertionCredentials 和 OAuth2DecoratorFromClientSecrets,但失败了。
credentials = GoogleCredentials.get_application_default()
service = discovery.build('storage', 'v1', credentials=credentials)
req = service.objects().insert(
bucket=bucket_name,
name=fileName,
media_body=media)
【问题讨论】:
标签: python-2.7 google-app-engine google-oauth google-cloud-storage