php - Google Drive API: copy file with service account -


edit: when copying files service account created via api, copy goes through, error persists , file id in error corresponds copy. when copying file service account not own (but has edit access to), copy not occur , file id in error original file.

the service account not seem have visibility outside of files created via api, , not have visibility copies of files.

=-=-=-=-=-=-=-=-=-=-=-=-=-

i getting same error question: google drive api copy() - 404 error except setup little different.

creating files works fine.

i trying create documents via copy not owned users still give them read / write / no download access. i'll happy if copies now.

here code:

    $service = googledrive::connect();      $copy = new \google_service_drive_drivefile();     $copy->settitle($documentname);      try {         $createdfile = $service->files->copy($source_id, $copy);     } catch (\exception $e) {         print "an error occurred: " . $e->getmessage();     } 

and output:

an error occurred: error calling post https://www.googleapis.com/drive/v2/files/1rxglhs8p4klcn28wtsf-qhj9bubiv0ay3r6pejitqcm/copy: (404) file not found: 1pkae72bi0ux3uav3vckv4pat_jsxhj5uzoy0f1secnw 

it seems there's issue permissions on destination file? how can verify if there's permission or authentication issue? i'm logged in oauth fine.

here client connection code:

static public function connect() {     self::$shared_folder = config('google.sharedfolder');      $client_email = config('google.serviceaccountemail');      // see if need recreate client     if (!googledrive::$client) {          $private_key = file_get_contents(config('google.serviceaccountkeyfile'));          googledrive::$client = new \google_client();          googledrive::$client->setapplicationname(googledrive::$app_name);         $credentials = new \google_auth_assertioncredentials(             $client_email,             googledrive::$scope,             $private_key         );         googledrive::$client->setassertioncredentials($credentials);     }      // see if token expired     if (googledrive::$client->getauth()->isaccesstokenexpired()) {         googledrive::$client->getauth()->refreshtokenwithassertion();     }      $_session['service_token'] = googledrive::$client->getaccesstoken();      return new \google_service_drive(googledrive::$client); } 

not complete answer, ended using regular account in domain , storing tokens copy files. not able use service account drive store , copy files. nor able grant users permissions files in service account drive. tried creating documents in regular user's drive service account owner copies , permissions failed. able create files service account owner, apparently either missing or doing not permissible.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -