Laravel 刷新令牌必须作为setAccessToken的一部分传入或设置。拉维尔
按照正确的说明,我得到以下错误:Laravel 刷新令牌必须作为setAccessToken的一部分传入或设置。拉维尔,laravel,google-drive-api,flysystem-google-drive,Laravel,Google Drive Api,Flysystem Google Drive,按照正确的说明,我得到以下错误: 刷新令牌必须作为setAccessToken的一部分传入或设置 来自GoogleDriveServiceProvider的代码: class GoogleDriveServiceProvider extends ServiceProvider { /** * Bootstrap the application services. * * @return void */ public function bo
刷新令牌必须作为setAccessToken的一部分传入或设置
来自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 Drive的代码:
Storage::disk('google')->put('test.txt', 'Hello World');
关于这个主题有几个答案,但它们都有干净的php和建议,在我看来,对Laravel来说是行不通的
UPD。Filesystem.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'),
],
];
您是否在config/filesystem.php
中设置了google配置?除非您更改了数据,否则不要共享任何关于它的信息,这样您的google帐户就不会被盗。我附加了filesystem.php,是否可以附加其他内容?我使用Heroku托管,.env
通过Heroku配置:add.
上传的数据可能与托管相关的细微差别?尝试(自己)执行dd(env())
,我认为应该打印所有可用的env
,这样您就可以看到,例如,MAIN\u GOOGLE\u DRIVE\u CLIENT\u ID
和其他设置正确