Skip to content

refresh token must be passed in or set as part of setAccessToken #16

Open
@mastria

Description

@mastria

Problem Explanation

The current implementation of the LaravelGoogleDriveStorage package contains a code snippet in the LaravelGoogleDriveStorageServiceProvider.php that dynamically sets the Google Drive configuration using environment variables. The relevant code is as follows:

app()->config['filesystems.disks.google'] = [
    'driver' => 'google',
    'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
    'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
    'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
    'folder' => env('GOOGLE_DRIVE_FOLDER'), // without folder is root of drive or team drive
];

Issue with config:cache

According to the official Laravel documentation, calls to the env() function outside configuration files will return null after caching the configuration. This leads to failures when using the package, especially when attempting to authenticate with Google Drive.

Consequences

As a result, users may encounter significant issues when trying to perform operations with Google Drive, such as uploading or downloading files, because the necessary credentials are not being properly retrieved. This creates a critical dependency on environment variables that cannot be fulfilled after caching the configuration.

Proposed Solution

To resolve this issue, the package should avoid directly setting the Google Drive configuration using the env() function within the service provider. Instead, it should utilize a dedicated configuration file that can be cached properly. This will ensure that the credentials are available even after running php artisan config:cache, thus maintaining the package's functionality without any errors.

Thank you for providing this package! I hope this suggestion helps improve its robustness.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions