刷新令牌必须传入或设置为 setAccessToken 的一部分 Laravel

问题描述

完全按照 these 说明,我收到以下错误

refresh token must be passed in or set as part of setAccesstoken

enter image description here

来自 GoogleDriveServiceProvider 的代码

class GoogleDriveServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        Storage::extend('google',function($app,$config) {
            $client = new Google_Client();
            $client->setClientId($config['clientId']);
            $client->setClientSecret($config['clientSecret']);
            $client->setAccesstype('offline');
            $client->refreshToken($config['refreshToken']);
            $service = new \Google_Service_Drive($client);
            $adapter = new GoogleDriveAdapter($service,$config['folderId']);

            return new Filesystem($adapter);
        });
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

我试图将文本文件上传到 Google 云端硬盘的控制器代码

Storage::disk('google')->put('test.txt','Hello World');

关于这个主题有几个答案,但他们有干净的 PHP 和建议,在我看来,对 Laravel 不起作用。

更新。文件系统.PHP

<?PHP

return [

    /*
    |--------------------------------------------------------------------------
    | Default Filesystem disk
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default filesystem disk that should be used
    | by the framework. The "local" disk,as well as a variety of cloud
    | based disks are available to your application. Just store away!
    |
    */

    'default' => env('FILESYstem_DRIVER','google'),/*
    |--------------------------------------------------------------------------
    | Default Cloud Filesystem disk
    |--------------------------------------------------------------------------
    |
    | Many applications store files both locally and in the cloud. For this
    | reason,you may specify a default "cloud" driver here. This driver
    | will be bound as the Cloud disk implementation in the container.
    |
    */

    // 'cloud' => env('FILESYstem_CLOUD','s3'),'cloud' => 'google',/*
    |--------------------------------------------------------------------------
    | Filesystem disks
    |--------------------------------------------------------------------------
    |
    | Here you may configure as many filesystem "disks" as you wish,and you
    | may even configure multiple disks of the same driver. Defaults have
    | been setup for each driver as an example of the required options.
    |
    | Supported Drivers: "local","ftp","sftp","s3"
    |
    */

    'disks' => [

        'local' => [
            'driver' => 'local','root' => storage_path('app'),],'public' => [
            'driver' => 'local','root' => storage_path('app/public'),'url' => env('APP_URL').'/storage','visibility' => 'public',// ...
        'google' => [
            'driver' => 'google','clientId' => env('MAIN_GOOGLE_DRIVE_CLIENT_ID'),'clientSecret' => env('MAIN_GOOGLE_DRIVE_CLIENT_SECRET'),'refreshToken' => env('MAIN_GOOGLE_DRIVE_REFRESH_TOKEN'),'folderId' => env('MAIN_GOOGLE_DRIVE_FOLDER_ID'),// ...

        's3' => [
            'driver' => 's3','key' => env('AWS_ACCESS_KEY_ID'),'secret' => env('AWS_SECRET_ACCESS_KEY'),'region' => env('AWS_DEFAULT_REGION'),'bucket' => env('AWS_BUCKET'),'url' => env('AWS_URL'),'endpoint' => env('AWS_ENDPOINT'),/*
    |--------------------------------------------------------------------------
    | Symbolic Links
    |--------------------------------------------------------------------------
    |
    | Here you may configure the symbolic links that will be created when the
    | `storage:link` Artisan command is executed. The array keys should be
    | the locations of the links and the values should be their targets.
    |
    */

    'links' => [
        public_path('storage') => storage_path('app/public'),];

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...