简体   繁体   English

Google云端硬盘api和服务帐户

[英]Google drive api and service account

I created service account for my account name@steelkiwi.com(Google apps) and my application works fine. 我为我的帐户name@steelkiwi.com(谷歌应用程序)创建了服务帐户,我的应用程序运行正常。 Then I created service account for my personal account name@gmail.com, use this new credentials for my application and now when I try to insert files I get error 500 with next text: 然后我为我的个人帐户name@gmail.com创建了服务帐户,为我的应用程序使用这个新凭据,现在当我尝试插入文件时,我得到错误500与下一个文本:

HttpError 500 when requesting https://www.googleapis.com/upload/drive/v2/files?quotaUser=30&uploadType=resumable&convert=true&ocr=false&alt=json returned "Internal Error" HttpError 500请求https://www.googleapis.com/upload/drive/v2/files?quotaUser=30&uploadType=resumable&convert=true&ocr=false&alt=json返回“内部错误”

The only thing that changes is credentials SERVICE_ACCOUNT_EMAIL and SERVICE_ACCOUNT_PKCS12_FILE_PATH. 唯一改变的是凭证SERVICE_ACCOUNT_EMAIL和SERVICE_ACCOUNT_PKCS12_FILE_PATH。 I have tried to create another service account for name@steelkiwi.com but it doesn't help, so bacically my app only works with first service account. 我曾尝试为name@steelkiwi.com创建另一个服务帐户,但它没有帮助,因此我的应用程序仅适用于第一个服务帐户。 Language is python. 语言是python。

If you create a service account with your apps domain admin, you should be able to impersonate all users by changing the prn attribute below. 如果您使用应用域管理员创建服务帐户,则应该可以通过更改下面的prn属性来模拟所有用户。 If you don't set a prn user that is out of your domain, you should see an access error. 如果您未设置域外的prn用户,则应该会看到访问错误。

f = open('path-to-privatekey.p12')
key = f.read()
f.close()

credentials = SignedJwtAssertionCredentials('xxx@developer.gserviceaccount.com', key, scope='https://www.googleapis.com/auth/drive', prn='user@steelkiwi.com')

http = httplib2.Http()
credentials.authorize(http)

client = build('drive', 'v2', http=http)

Ok, I'm not sure what happened maybe something was fixed after this accident http://www.google.com/appsstatus#hl=en&v=issue&ts=1366405199000&iid=369723584758ad9cdfd010ac44c8272e but now all works fine. 好吧,我不确定发生了什么事可能在事故发生后修复了一些内容http://www.google.com/appsstatus#hl=zh-CN&v=issue&ts=1366405199000&iid=369723584758ad9cdfd010ac44c8272e但现在一切正常。 At first I created simple small app from examples that work with service accounts https://gist.github.com/mobedigg/5420958 I have used my credentials for this app and it's works so I put this credentials to my main code and it's worked too. 起初我使用服务帐户的示例创建了一个简单的小应用程序https://gist.github.com/mobedigg/5420958我已经使用了我的凭据这个应用程序,它的工作原理,所以我将这些凭据放到我的主代码中,它的工作原理太。 Nothing was changed in main code except credentials. 除了凭证之外,主代码中没有任何更改。 Also I tried other credentials on this small app and they are worked with it and worked with main code. 此外,我在这个小应用程序上尝试了其他凭据,他们使用它并使用主代码。 It's very odd. 这很奇怪。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用服务帐户密钥的 Google Drive Python API 授权 - Google Drive Python API authorization using service account key 如何在Google的python API和驱动器上使用服务帐户? - How to use a service account with Google's python api and drive? 使用共享设备和服务帐户获取文件夹和文件 Google Drive API - Get folder and files Google Drive API with Shared Device and Service Account Google Drive API服务帐户“用户已超过其Drive存储配额” python - Google Drive API service Account “The user has exceeded their Drive storage quota” python Google API服务帐户 - Google API Service Account Google API 服务帐户。 即使使用域范围的委派访问,也只能看到服务帐户驱动器 - Google API Service Account. Can only see service accounts drive even with Domain Wide Delegation Access Google云端硬盘服务帐户未经授权的客户端例外 - Unauthorized Client Exception with Google Drive Service Account Google Drive 使用服务帐户验证和下载文件 - Google Drive Authenticate and Download Files with Service Account Google Drive API 使用 python 中的服务帐户未显示与我共享的文件夹 - Google Drive API using Service Account in python not showing up folders that are shared to me Google Drive API 服务帐户身份验证以使用 Python 上传图像文件并将其插入到复制的文档中 - Google Drive API Service Account authentication to upload and insert an image file to into copied doc using Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM