Using Google Drive's API I'm able to get authorization and a token, but in trying to get a list of files, the API currently returns only one item: a PDF named "Getting Started". Presumably that's the default item in a just-established Google Drive -- an item long since deleted from the intended Google Drive Account we're working with.
Meanwhile using the API Explorer (https://developers.google.com/apis-explorer) returns hundreds of items which are, in fact, representative of the Google Drive for the account in question.
API Explorer says the request it sent was:
GET https://www.googleapis.com/drive/v3/files?corpus=user&pageSize=100&key={YOUR_API_KEY}
Sending that directly returns an "insufficient permissions" error, which makes sense: it's the api_key, not the access_token
Switching &key=
with &access_token=
does return a file list, but the only item in it is the "Getting Started" PDF mentioned above.
The discrepancy between API and the Explorer gives the impression that...
a) Each is referencing a different account, or
b) The permissions / scope / access granted in the API Console (https://console.developers.google.com) are narrow than Explorer
Regarding a) Each referencing a different account: Not likely. The credentials were all created in the API Console while logged into the same Google Account that was used to run API Explorer.
Regarding b) The permissions / scope / access are somehow different: Much more likely, but so far it's not immediately obvious how or what to adjust to make a difference.
The cURL calls sent:
curl https://www.googleapis.com/drive/v3/files?corpus=user&pageSize=100&key={YOUR_API_KEY} (NG. Needs a token)
curl https://www.googleapis.com/drive/v3/files?corpus=user&pageSize=100&access_token={recently_obtained_token} (this works, but returns only one item -- the "Getting Started" PDF)
The Return:
{"kind": "drive#fileList", "incompleteSearch": false, "files": [{"kind": "drive#file", "id": "XXXX", "name": "Getting started", "mimeType": "application/pdf"}]}
The authorization and token steps used to get this far are listed here... How to connect to the Google Drive API using cURL?
Per this post (Access Google Drive API Returns Empty File List)
The scope used was indeed https://www.googleapis.com/auth/drive
Under the same link one kvzrock's answers suggests giving "permission to the email address of the service account"
Couple of links on that:
Google Drive API, Oauth and service account
How do I authorise an app (web or installed) without user intervention?
But no luck understanding those yet.