Laravel - Google Sheets API 为空或缺少范围

标签 laravel google-sheets google-api

所以我一直在尝试制作一个网络应用程序,使用https://github.com/kawax/laravel-google-sheets从谷歌工作表中提取数据。 .

我早些时候在工作时设置了这个,效果很好。数据返回没有问题,但是当我尝试将其带回本地服务器上的家庭电脑时,它给了我一个我以前从未见过的错误,并且我正在努力调试。

Google_Service_Exception (400)
{ "error": "invalid_scope", "error_description": "Empty or missing scope not allowed." }

这个问题似乎只在我运行这行代码时出现:

 $values = Sheets::sheet('Sheet1')->all();

该区域的完整代码是:

<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Sheets;
use Datetime;
use Google;
Use Carbon\Carbon;
class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
    public function test()
    {
      Sheets::setService(Google::make('sheets'));
      Sheets::spreadsheet('1yYpNNpPPrbraIZeaoQ5v80MobkI9Nv14oLI_S2_RJhY');
      $values = Sheets::sheet('Sheet1')->all();
      // all() returns array

     // Do stuff with data

如有任何帮助,我们将不胜感激。

最佳答案

在你的 config/google.php 添加(完成 php artisanvendor:publish 之后)

'scopes'           => [\Google_Service_Sheets::DRIVE, \Google_Service_Sheets::SPREADSHEETS],

然后它应该再次开始工作。

关于Laravel - Google Sheets API 为空或缺少范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48836695/

相关文章:

javascript - 如何重新格式化对象中的数据。 (我如何使行成为键,其他列成为值)

android - google map api中SHA1指纹的用法是什么

javascript - 如何用 "String"替换 Google 表格列中非空单元格的值?

Laravel 广播推送器事件多次触发

php - 我该如何编写它,使其只访问数据库一次?

laravel - gulp 通知 : [Error in notifier] Error in plugin 'gulp-notify' not found: notify-send

javascript - 查询错误 : Invalid JSON string when Creating a Chart from a Spreadsheet? GAS

python - 为什么在执行转发电子邮件的代码时出现访问限制错误?

google-api - 从 Google Drive API 获取操作项列表

mysql - 当我迁移文件时它只显示 varchar(191) 而不是 255