Studio-42 / elFinder

📁 Open-source file manager for web, written in JavaScript using jQuery and jQuery UI
https://studio-42.github.io/elFinder/
Other
4.64k stars 1.42k forks source link

Google drive options client_id and client_secret in roots don't work #3524

Closed Nounours13 closed 1 year ago

Nounours13 commented 2 years ago

Hi, On line 108 to 121 on elFinderVolumeGoogleDrive.class.php there is all options for Gdrive connection:

       $opts = [
                  'client_id' => '',
                  'client_secret' => '',
                  'access_token' => [],
                  'refresh_token' => '',
                  'serviceAccountConfigFile' => '',
                  'root' => 'My Drive',
                  'gdAlias' => '%s@GDrive',
                  'googleApiClient' => '',
                  'path' => '/',
                  'tmbPath' => '',
                  'separator' => '/',
                  'useGoogleTmb' => true,
                  'acceptedName' => '#.#',
                   ....__

If I use :

        roots = array(
                             array(
                                        'driver'                => 'GoogleDrive',
                                        'refresh_token'   => '1//xxxxxx',
                                         'client_id'           => '513xxxxxxxxxxxxxxxxx',
                                         'client_secret'     => 'GOxxxxxxxxxxxxxxxxxx',
                                    'path'            => '/',
                                        'root'                    => 'My GDrive'
                                      );  
                              );_  

all options are taken except client_id and client_secret

I must add :

    define('ELFINDER_GOOGLEDRIVE_CLIENTID','513xxxxxxxx');
    define('ELFINDER_GOOGLEDRIVE_CLIENTSECRET', 'GOCxxxxxxx');

otherwise i've an error : "Driver \"elFinderVolumeGoogleDrive\" : Required option \"client_id\" is undefined."

I don't understand why it doesn't work with the roots declaration because, in line 620 on elFinderVolumeGoogleDrive.class.php there are:

    public function netmountPrepare($options)
        {
            if (empty($options['client_id']) && defined('ELFINDER_GOOGLEDRIVE_CLIENTID')) {
                $options['client_id'] = ELFINDER_GOOGLEDRIVE_CLIENTID;
            }
            if (empty($options['client_secret']) && defined('ELFINDER_GOOGLEDRIVE_CLIENTSECRET')) {
                $options['client_secret'] = ELFINDER_GOOGLEDRIVE_CLIENTSECRET;
            }
            if (empty($options['googleApiClient']) && defined('ELFINDER_GOOGLEDRIVE_GOOGLEAPICLIENT')) {
                $options['googleApiClient'] = ELFINDER_GOOGLEDRIVE_GOOGLEAPICLIENT;
                include_once $options['googleApiClient'];
            }

I don't know if it's me who made a mistake or if it's a bug. thank you for your reply.

Otherwise, using the define, it works fine.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 50 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.