Laravel - Google表格API空白或缺少范围

问题描述 投票:0回答:1

所以我一直试图制作一个使用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

任何帮助,将不胜感激。

laravel google-sheets google-api
1个回答
0
投票

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

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

然后它应该重新开始工作。

© www.soinside.com 2019 - 2024. All rights reserved.