omnidrive / gdrive
Omnidrive Google Drive: a folder of Google Drive (My Drive or a shared drive) as an omnidrive drive, through masbug/flysystem-google-drive-ext - OAuth refresh token or service account, paths by name.
Requires
- php: >=8.2
- google/apiclient: ^2.15
- google/auth: ^1.37
- guzzlehttp/guzzle: ^7.0
- masbug/flysystem-google-drive-ext: ^2.5
- omniscient/omnidrive: ^1.0@dev
Requires (Dev)
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-24 05:10:49 UTC
README
A folder of Google Drive - My Drive, a shared drive, or a folder shared with the account - as an omnidrive drive, through masbug/flysystem-google-drive-ext (google/apiclient): paths by name, as Drive's web page shows them.
composer require omniscient/omnidrive omnidrive/gdrive
use Omnidrive\Gdrive\GdriveDriveFactory; use Omnidrive\Registry; $drives = new Registry([new GdriveDriveFactory()], [ 'drive' => ['factory' => 'gdrive', 'options' => ['client_id' => getenv('GOOGLE_CLIENT_ID'), 'client_secret' => getenv('GOOGLE_CLIENT_SECRET'), 'refresh_token' => getenv('GOOGLE_REFRESH_TOKEN'), 'root' => 'Site/uploads']], 'team' => ['factory' => 'gdrive', 'options' => ['service_account' => '/run/secrets/drive.json', 'shared_drive_id' => '0ABCdefGHIjk']], ]);
| Option | Default | |
|---|---|---|
client_id, client_secret, refresh_token |
an OAuth client and an account's refresh token: the access token renewed on its own | |
service_account |
instead: a service account's JSON key - its path, the JSON, or the array | |
subject |
with a service account: the Workspace user it acts as (domain-wide delegation) | |
root |
the Drive's root | the folder behind the drive's paths: a path of names, or an ID with display_paths false |
shared_drive_id, shared_folder_id |
a shared drive, a folder shared with the account | |
display_paths |
true | paths are names; false: paths are file IDs |
permanent_delete |
false | false: a deleted file goes to the bin |
public_url |
Drive serves no public address of its own |
A file "public" is shared with anyone who has the link (reader), "private" is not. With root as a
path of names the folder is looked up when the drive is built (the adapter's way); otherwise nothing
is sent until the first operation. The service account's credentials are given to Google's client as
such, so its token is fetched through the HTTP client the factory is given - as application-default
credentials the adapter would fetch it through Google's default one. google/apiclient brings
google/apiclient-services, every Google API's classes: Google's README gives the Composer script
that keeps only Drive's.
Verified, and not
- Verified (2026-10-24, omnidrive's harness, PHP 8.4), offline: the refresh token exchanged at Google's token endpoint on the first operation, not when the drive is built, and Drive's API asked with the token it gives; a service account's assertion signed with its key, for its subject and Drive's scope; the options required.
- Not verified: Google Drive itself - no account here:
GdriveLiveTestruns the contract against an account withOMNIDRIVE_GDRIVE_CLIENT_ID,_CLIENT_SECRETand_REFRESH_TOKEN, orOMNIDRIVE_GDRIVE_SERVICE_ACCOUNT(and_SHARED_DRIVE_ID), in the folderOMNIDRIVE_GDRIVE_ROOT; so neither the contract's operations, visibility as sharing, shared drives, nor Google Docs files (exported by the adapter) have been seen against Drive.
License: MIT. Unofficial; not affiliated with Google or masbug.