polyhas.blogg.se

Google drive api php
Google drive api php










$client->setAuthConfig('credentials.json') $client->setScopes(Google_Service_Drive::DRIVE) I was able to reproduce via google example setApplicationName('Google Drive API PHP Quickstart') $result = $service->files->create($folder) $folder = new Google_Service_Drive_DriveFile() $service = new Google_Service_Drive($client) $client->setAccessToken('ya29.a0AfH6SMDO-L_7Lp6YWbGtSqWdPHJKCNezQr8-RRgS8xslHInLApC9uxBJVVljPTKEBgR-iidqIorjNaBThU4-aPjuAth1aD7mzjJXn5n2xP1xPw40p_OLssC7Ttj8CpBJHuqsUm89CYWAGL8cCHGhQ2hBY0YjKQ') $client->addScope(Google_Service_Drive::DRIVE) My function : public function createFolder($name) I do not really understand where this can come from knowing that I have set the scope indicated in the documentation: $client->addScope(Google_Service_Drive::DRIVE) "message": "Insufficient Permission: Request had insufficient authentication scopes." I used Tailwind CSS and React, but you could use anything.Recently I have set up an automatic file creation system on the google drive, I have integrated the API into my symfony application, I manage to authenticate myself, etc., but I do not block on the step of creation of the file. The majority of the work required to make drive.tools/copy-folder was creating the UI.

google drive api php

So using this, we can tell the query to only look for folders and make sure they are not in the trash. You NEED to enable the API before adding the scope, otherwise it won’t show up! Instead I create a project in Firebase instead of Google Cloud because it automatically creates an OAuth client and API key for you, saving a few steps.Īfter you have this project, you need to enable the Drive API and add the Drive scope to the OAuth client. The buttons on that page seem to create a new Google Cloud project, which is less useful if you already have a project you want to use. There are some things to keep in mind though, especially around project and OAuth client creation. The first thing I did was look at the Google Drive Browser Quickstart. This would both be faster and more secure as the Google Drive credentials never need to be stored or used by any server side code.

google drive api php

The big goal for this app is that I wanted everything to run in the browser. Note: This is not a step-by-step tutorial, I’m going to be focusing on the parts I found challenging / confusing so other folks trying similar things won’t be caught in the same way. Looking online, there were a bunch of people creating workarounds using things like Apps Script or even the Google Drive desktop app to copy the folder locally and reupload it!Īs a fun challenge, I wanted to see if I could build a tool in 24 hours that let you copy a folder without jumping through hoops.

google drive api php google drive api php

Recently we needed to copy a folder in Google Drive.












Google drive api php