Google APPs managed “unlimited” account storage quota for service account

我与影子孤独终老i 提交于 2019-12-04 18:25:01

A service account is not you. Think of a service account as a dummy Google user, it has its own Google drive account, Google calendar account ...

It is probably loosely related to the developers who have access to it in the Google developer console, if the application using the service account starts to spam Google drive the developer console account will be shut down. But beyond that you and any service accounts you create are separate entity's. It doesn't have access to your unlimited drive account until you give it access to your unlimited drive account. (wish I had an unlimited drive account)

Now it is an entity, but I am not all that sure the school could give it access. Really I am not sure I would want to it would remove one part of the control of the service account from me. Some school admin could just remove it one day and break everything .....

What I suggest you do is this, give the service account access to your Google account. Open Google drive the web version. I suggest you create a new directory. In the sharing permissions take the service accounts email address and give it full access to that directory. It should then be able to upload to the directory of your amazing unlimited drive account.

Update Just thought of something: You are probably going to have to check what directories it has access to once you give it access to your drive directory. You will need to be sure it uploads to the drive you shared and not its root directory.

update Permissions:

You are probably using file.insert to upload the file. that is just the first step.

Once you have the file uploaded you will need to patch it, and change the permissions grating you as in you personally not the service account access to the file. When the file is uploaded its still OWNED by the service account.

You will need to use Files: patch to update the permissions on the file and granting you as in you not the service account access to the file.

Unfortunately its not possible (at this time) to set the permissions of the file when its uploaded. I am not sure if this is a bug or its just not supported i created an issue request on this a few days ago. Issue 3717: Google drive api, upload file with shared permission

It seems that it's impossible to transfer the ownership of the files uploaded by service account to the main account.

Finally I abandoned the service account approach and followed this approach to run my app as my regular user.

Once the steps described there were accomplished, I create the drive service like that:

import httplib2
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive

gauth = GoogleAuth()
gauth.LoadCredentialsFile("GoogleDriveCredentials.txt")
if gauth.credentials is None:
    gauth.LocalWebserverAuth()
elif gauth.access_token_expired:
    print "Google Drive Token Expired, Refreshing"
    gauth.Refresh()
else:
    gauth.Authorize()
gauth.SaveCredentialsFile("GoogleDriveCredentials.txt")
drive = GoogleDrive(gauth) 

Where GoogleDriveCredentials.txt is of the form:

{"_module": "oauth2client.client", "token_expiry": "XXX", "access_token": "XXX", "token_uri": "https://accounts.google.com/o/oauth2/token", "invalid": false, "token_response": {"access_token": "XXX", "token_type": "Bearer", "expires_in": 3600}, "client_id": "XXX.apps.googleusercontent.com", "id_token": null, "client_secret": "XXX", "revoke_uri": "https://accounts.google.com/o/oauth2/revoke", "_class": "OAuth2Credentials", "refresh_token": "XXX", "user_agent": null}

Now the uploaded files' owner is "me" in web interface and they are accounted in my main account's storage quota, so my goal is reached.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!