Google Drive API, Oauth and service account

I've some issues with Google Drive API, service account and authentication. I red really a lot but I cannot figure out how to solve this.

Context: I have some files on my Drive account (about 35GB) and a simple web app which let users to log in, see some selected folders/files from my Drive and download them if needed. The only one who can directly access to my Drive account is (or should be) my server, users do their stuff through web app/server.

After some search I found server-to-server docs (https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that should be perfect for my purpose BUT, as I can see, service account does not share same Drive space: they have their own and it's not upgradable. Because of this (weird) limit I cannot use service account since I have more than 35GB and I need to "share" everything.

Other way: use "standard" Oauth in order to obtain an access token and then use it to make call to Drive API, but access tokens have an expire date and I can't update it manually every time.

So, first question: is there a way to increase quota for service account? If not, if there a way to use my "normal" account (owner) acting like a service account?

Second (dummy) question: I red docs about creating new Oauth credentials (https://developers.google.com/drive/v3/web/quickstart/php) and at the end you obtain some example code and "client-secret" json. I run the example but I didn't understand whats the role of that json file: I must log in and give permission anyway, why I need it?

Third (dummy enough) question: if Oauth is the only solution, is there a way to obtain/refresh access tokens without doing it manually every time? I looked at Oauth docs and "user interaction/confirmation" is one of the basics thing in auth flow, so I don't think is possibile but...

If needed I can post some code and/or example.

Thanks a lot for your help!


Share your Drive account's folder to your service account.
Your service account's addresss looks like XXX@XXX.iam.gserviceaccount.com.
Then your service account can see the shared folder from your Drive account.
So you have 35GB service account.

链接地址: http://www.djcxy.com/p/63058.html

上一篇: 如何设计Joomla 2.5文章的介绍文字?

下一篇: Google Drive API,Oauth和服务帐户