Kirill
Kirill

Reputation: 41

Google drive api and service account

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.

Upvotes: 4

Views: 3260

Answers (2)

Kirill
Kirill

Reputation: 41

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.

Upvotes: 0

Burcu Dogan
Burcu Dogan

Reputation: 9213

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)

Upvotes: 0

Related Questions