4
votes

I created service account for my account [email protected](Google apps) and my application works fine. Then I created service account for my personal account [email protected], use this new credentials for my application and now when I try to insert files I get error 500 with next text:

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"

The only thing that changes is credentials SERVICE_ACCOUNT_EMAIL and SERVICE_ACCOUNT_PKCS12_FILE_PATH. I have tried to create another service account for [email protected] but it doesn't help, so bacically my app only works with first service account. Language is python.

2
Are you using Google APIs python client library?Burcu Dogan
In normal circumstances, all you need to change is the email and the private key and 500 is not expected due to wrong credentials.Burcu Dogan
Yes, I'm use google-api-python-client. And I have exponential backoff but it doesn't help in this case.Kirill
Which user are you trying to impersonate? Impersonation is not available for gmail accounts, but only for Google Apps domain admins.Burcu Dogan
I'm not sure that I understand your answer. Both account are mine.Kirill

2 Answers

0
votes

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. If you don't set a prn user that is out of your domain, you should see an access error.

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

credentials = SignedJwtAssertionCredentials('[email protected]', key, scope='https://www.googleapis.com/auth/drive', prn='[email protected]')

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

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

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. 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. 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.