Kyle Wardle
Kyle Wardle

Reputation: 830

Laravel - Google Sheets API Empty or missing scope

So I have been trying to make a web application which pulls data from a google sheet using https://github.com/kawax/laravel-google-sheets .

I had set this up earlier whilst at work and it worked fine. The data returned no problem however when I tried bringing it back to my home PC on a local server, it gave me an error I have not seen before and am seriously struggling to debug.

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

This problem only seems to apply when I run this line of code :

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

The whole code for that area is :

<?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

Any help would be appreciated.

Upvotes: 2

Views: 1387

Answers (1)

user2087032
user2087032

Reputation: 98

In your config/google.php add (after you have done php artisan vendor:publish)

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

Then it should start working again.

Upvotes: 2

Related Questions