微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决刷新令牌必须传入或设置为 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.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?