Reputation: 1816
I'm using the following code to connect and make my requests to G-API:
require_once '/google-api/vendor/autoload.php';
putenv('GOOGLE_APPLICATION_CREDENTIALS=/mySecretFile.json');
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope("https://www.googleapis.com/auth/drive");
$service = new Google_Service_Drive($client);
$files = $service->files->listFiles()->getFiles();
foreach($files as $file){
print_r($file);
}
I tried this code a couple of times, and all of them the result comes with just 1 file, which I believe it's no mine, since it doesn't exist in my drive, so what's happening? There is the image of the only file I'm getting.
Upvotes: 0
Views: 83
Reputation: 116948
You appear to be authenticating with a service account. Think of a service account as a dummy user. Service accounts have their own Google drive account, google calendar and probably a bunch more.
The file you are seeing is probably a file on its drive account. If you want it to have access to your personal drive account then you will have to take the service account email address and share which ever directory you want it to have permission to access with it.
Note: No you cant share root folder
Upvotes: 1