
Yep, that’s right - talk to Gmail, Docs, Sheets, Drive, Forms, Calendar and much more. Secondly, I’m using Google Apps Script to listen for the submit event and handle the logic server-side.Īpps Script? What on earth is that I hear you ask? As Google put it “Many Google apps, one platform in the cloud”. Exchange authorization code for an access token.So, I automated the whole process - invoice creation and insertion into the correct “month” folder inside the correct “year”.įirst, I’m now using a Google Form to enter the customer and order details. Printf("Open the following link in your browser:\n%s\n", $authUrl) $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken()) Refresh the token if possible, else fetch a new one. If there is no previous token or it's expired. $accessToken = json_decode(file_get_contents($tokenPath), true) created automatically when the authorization flow completes for the first The file token.json stores the user's access and refresh tokens, and is Load previously authorized token from a file, if it exists. $client->setPrompt('select_account consent') $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) $client->setAuthConfig('code_secret_client.json') 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." 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.
