[英]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.