Code Monkey home page Code Monkey logo

Comments (8)

erikn69 avatar erikn69 commented on July 22, 2024 1

@foremtehan try this branch: GoogleDriveAdapter.php, if that works i make a PR

from flysystem-google-drive-ext.

erikn69 avatar erikn69 commented on July 22, 2024 1

Ok, this time i found the solution, but you have to change your config

Runtime:       PHP 8.0.5
Configuration: /google_flysystem/phpunit.xml.dist
..                                                                  2 / 2 (100%)
Time: 00:08.995, Memory: 8.00 MB
OK (2 tests, 9 assertions)

First you have to create a google service account and get auth config json file

Then change the old config for the new one ( you can look at this: GoogleDriveAdapterTests.php )
before:

$client->setClientId($config['GOOGLE_DRIVE_CLIENT_ID']);
$client->setClientSecret($config['GOOGLE_DRIVE_CLIENT_SECRET']);
$client->refreshToken($config['GOOGLE_DRIVE_REFRESH_TOKEN']);

after: (here you can add GOOGLE_DRIVE_SERVICE_JSON to .env but if you use a same path of your project, add the path to .gitignore file too, for security)

$client->setAuthConfig($config['GOOGLE_DRIVE_SERVICE_JSON']);  // must be full path to json file(first step)
$client->setApplicationName($config['GOOGLE_DRIVE_SERVICE_APP_NAME'] ?? 'Your Name Application');
$client->setScopes(['https://www.googleapis.com/auth/drive']);

Finally try this branch GoogleDriveAdapter.php and tell me later if works and i will make a PR

from flysystem-google-drive-ext.

foremtehan avatar foremtehan commented on July 22, 2024

@erikn69 i get this exception after one hour:

DomainException: set the JSON service account credentials using Google\Client::setAuthConfig or set the path to your JSON file with the "GOOGLE_APPLICATION_CREDENTIALS" environment variable and call Google\Client::useApplicationDefaultCredentials to refresh a token with assertion.#0 /app/vendor/google/apiclient/src/Client.php(265): Google\Client->fetchAccessTokenWithAssertion()

#1 /app/vendor/masbug/flysystem-google-drive-ext/src/GoogleDriveAdapter.php(302): Google\Client->refreshTokenWithAssertion()
#2 /app/vendor/masbug/flysystem-google-drive-ext/src/GoogleDriveAdapter.php(1160): Masbug\Flysystem\GoogleDriveAdapter->refreshToken()
#3 /app/vendor/masbug/flysystem-google-drive-ext/src/GoogleDriveAdapter.php(1773): Masbug\Flysystem\GoogleDriveAdapter->getItems()
#4 /app/vendor/masbug/flysystem-google-drive-ext/src/GoogleDriveAdapter.php(1938): Masbug\Flysystem\GoogleDriveAdapter->cachePaths()
#5 /app/vendor/masbug/flysystem-google-drive-ext/src/GoogleDriveAdapter.php(638): Masbug\Flysystem\GoogleDriveAdapter->toVirtualPath()
#6 /app/vendor/league/flysystem/src/Filesystem.php(58): Masbug\Flysystem\GoogleDriveAdapter->has()
#7 /app/vendor/league/flysystem/src/Filesystem.php(99): League\Flysystem\Filesystem->has()
#8 /app/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php(249): League\Flysystem\Filesystem->put()
#10 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\Jobs\BackupSubtitle->handle()
#11 /app/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#12 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
#13 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()
#14 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\Container\BoundMethod::call()
#15 /app/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(128): Illuminate\Container\Container->call()
#16 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}()
#17 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#18 /app/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(132): Illuminate\Pipeline\Pipeline->then()
#19 /app/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(120): Illuminate\Bus\Dispatcher->dispatchNow()
#20 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Queue\CallQueuedHandler->Illuminate\Queue\{closure}()
#21 /app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#22 /app/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(122): Illuminate\Pipeline\Pipeline->then()
#23 /app/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(70): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware()
#24 /app/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): Illuminate\Queue\CallQueuedHandler->call()
#25 /app/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(428): Illuminate\Queue\Jobs\Job->fire()
#26 /app/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(378): Illuminate\Queue\Worker->process()
#27 /app/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(172): Illuminate\Queue\Worker->runJob()
#28 /app/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(117): Illuminate\Queue\Worker->daemon()
#29 /app/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\Queue\Console\WorkCommand->runWorker()
#30 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle()
#31 /app/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#32 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
#33 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()
#34 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\Container\BoundMethod::call()
#35 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\Container\Container->call()
#36 /app/vendor/symfony/console/Command/Command.php(299): Illuminate\Console\Command->execute()
#37 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run()
#38 /app/vendor/symfony/console/Application.php(978): Illuminate\Console\Command->run()
#39 /app/vendor/symfony/console/Application.php(295): Symfony\Component\Console\Application->doRunCommand()
#40 /app/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun()
#41 /app/vendor/laravel/framework/src/Illuminate/Console/Application.php(92): Symfony\Component\Console\Application->run()
#42 /app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Console\Application->run()
#43 /app/artisan(37): Illuminate\Foundation\Console\Kernel->handle()
#44 {main}

from flysystem-google-drive-ext.

foremtehan avatar foremtehan commented on July 22, 2024

just one thing. is service account is separated from google drive storage ? i'm seeing files successfully uploaded but cannot see them in google drive

I set up a new gmail account with fresh service account, the files wouldn't store to the main drive, is there anyway that i could see the files in web ui ?

from flysystem-google-drive-ext.

erikn69 avatar erikn69 commented on July 22, 2024

@foremtehan last try GoogleDriveAdapter.php, forget all about create a google service account, and use only default first config

$client->setClientId($config['GOOGLE_DRIVE_CLIENT_ID']);
$client->setClientSecret($config['GOOGLE_DRIVE_CLIENT_SECRET']);
$client->refreshToken($config['GOOGLE_DRIVE_REFRESH_TOKEN']);

from flysystem-google-drive-ext.

foremtehan avatar foremtehan commented on July 22, 2024

Ok let me try that, that service account thing looks complicated https://stackoverflow.com/questions/49663359/how-to-upload-file-to-google-drive-with-service-account-credential

from flysystem-google-drive-ext.

foremtehan avatar foremtehan commented on July 22, 2024

@erikn69 i didnt see any issue thanks for your time <3

from flysystem-google-drive-ext.

erikn69 avatar erikn69 commented on July 22, 2024

Ok then i will do a PR for this

from flysystem-google-drive-ext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.