I was wondering is there any method to upload the files directly to our own Google drive by using php , Currently i am using a method like this. 

```
            $drive = new Google_Client();
            $drive->setClientId($client_id);
            $drive->setClientSecret($client_secret);
            $drive->setRedirectUri($redirect_uri);
            $drive->setScopes(array('https://www.googleapis.com/auth/drive'));

            $gdrive = new Google_DriveService($drive);

            $_GET['code'] = 'ya2-------------------------OZXiA';

            //file_put_contents('token.json', $drive->authenticate());

            $drive->setAccessToken(file_get_contents('token.json'));

            $doc = new Google_DriveFile();

            $doc->setTitle('Test Document');
            $doc->setDescription('Test description');
            $doc->setMimeType('text/plain');

            $content = file_get_contents('/assets/new--detils.txt');

            $output = $gdrive->files->insert($doc, array(
                'data' => $content,
                'mimeType' => 'text/plain',
            ));
            print_r($output);

```

But this shows an error as 

Fatal error: Uncaught exception `Google_AuthException` with message 'Error fetching OAuth2 access token, message: 'invalid\_grant'' in `/var/www/path/src/auth/Google_OAuth2.php:115`

Here i am using `$_GET['code'] = 'ya2-------------------------OZXiA'` generated for that app, 

Can anyone please suggest a method to do this, thanks in advance.