A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://stackoverflow.com/questions/78889065/get-file-name-from-id-with-google-drive-php-library below:

Get file name from id with Google Drive PHP Library

I'm using the Google PHP Library with a service account and I'm trying to get the name of a document in a shared team drive by using the document ID. The service account is a content manager on the shared drive. The code below results in code 404, File not found.

PHP Code
$client = new \Google_Client();
$client->setApplicationName('Google API Test');
$client->setScopes([\Google_Service_Drive::DRIVE]);
$client->setAccessType('offline');
$client->setAuthConfig('credentials.json);

$service = new \Google_Service_Drive($client); 

$files = $service->files->get('xxxxxxxxxxxxxxxxxxxxxxxxxxx');

echo "File Name: " . $file->getName();
Full Error Message
PHP Fatal error:  Uncaught Google\Service\Exception: {
  "error": {
    "code": 404,
    "message": "File not found: xxxxxxxxxxxxxxxxxxxxxxxxxxx.",
    "errors": [
      {
        "message": "File not found: xxxxxxxxxxxxxxxxxxxxxxxxxxx.",
        "domain": "global",
        "reason": "notFound",
        "location": "fileId",
        "locationType": "parameter"
      }
    ]
  }
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4