I am kinda lost in google api documentation jungle... need some help
I run a SaaS service hosted on AWS. I want to write a tiny python non-interactive script that
- runs on my linux in AWS
- periodically pulls certain files out of some unrelated google drive users (who want to authorize me to pull these files but I don't know how to guide them)
But I am lost in the liguistic jungle (English is not my mothertongue) of google api docs. Have spent hours with nothing to show... except frustration. I have also gone through many SO posts.
To begin with I can't even tell if this is feasible with google drive. All examples I saw are for App Data and not User Data. I know it would be trivial with AWS S3 or an FTP server.
Any help would be greatly appreciated.
----EDIT 1 (for Klaus D.)
Below is the scenario that I am trying to map, and the steps I have run so far
- there is a file owner. This is typically someone from outside my company. I have created a test google account, created a folder and populated a few files in there. I am calling it "file-owner-test@gmail.com"
- For this user, I created a project "proj-xxx", enabled Drive API, created a service account "prod-xxx-service-account".
- Next I checked "furnish private key" and which downloaded a JSON file that I saved as "test-credentials.json", transferred to my linux box. I left "domain wide" checkbox unchecked.
On my linux box, I am now trying out the python quickstart script shown here , setting credential_path to the downloaded file. But it breaks on
store.get()
:store = oauth2client.file.Storage(credential_path) credentials = store.get()
with a crisp KeyError: _module
.
File "./testprog.py", line 44, in get_credentials
credentials = store.get()
File "build/bdist.linux-x86_64/egg/oauth2client/client.py", line 421, in get
File "build/bdist.linux-x86_64/egg/oauth2client/file.py", line 66, in locked_get
File "build/bdist.linux-x86_64/egg/oauth2client/client.py", line 317, in new_from_json
KeyError: '_module'
I see there are unanswered SO questions on that here and also on github.
The credentials file looks like this:
{
"type": "service_account",
"project_id": "proj-xxx",
"private_key_id": "40-characters-wide-gibberish",
"private_key": "-----BEGIN PRIVATE KEY-----\nmulti-line-private-key\n-----END PRIVATE KEY-----\n",
"client_email": "prod-xxx-service-account@proj-xxx.iam.gserviceaccount.com",
"client_id": "21-digit-number",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/prod-xxx-service-account%proj-xxx.iam.gserviceaccount.com"
}
So, this is basically trying to get own user data using a credentials file in a non-interactive way. But the API is rather unclear (very secure!!). I probably also have made other mistakes in the steps so far. And I am not yet done - I will next need to add some permissions to this service account!
I hope this adds enough clarity for someone-who-knows to provide a little guidance. Thanks.