Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Paj4love's avatar

LogicException: refresh token must be passed in or set as part of setAccessToken

Hello friends! i have this error from my laravel webapp when i try uploading a file, like image to google drive, am sure my seetings are right please what am i doing wrong? Please am new to Google Drive API and using it as a storage. these are my codes:

GoogleDriveServiceProvider

public function boot()
{
    \Storage::extend("google", function($app, $config) {
        $client = new Google_Client();
        $client->setClientId($config['clientId']);
        $client->setClientSecret($config['clientSecret']);
        $client->refreshToken($config['refreshToken']);
        $service = new \Google_Service_Drive($client);
        $adaptor = new GoogleDriveAdaptor($service, $config['folderId']);
        return new Filesystem($adaptor);
    });
}

My Route:

Route::get('upload', function() { return view('upload'); });

Route::post('/upload', function (Request $request) { dd($request->file("thing")->store("", "google")); });

My blade.php

			<div class="mt-5 col-12">
                <form action="/upload" method="post" enctype="multipart/form-data">
                    @csrf
                    <input type="file" class="form-control" name="thing">
                    <br>
                    <input type="submit" class="btn btn-sm btn-block btn-danger" value="upload">
                </form>
            </div>

My blade.php

			<div class="mt-5 col-12">
                <form action="/upload" method="post" enctype="multipart/form-data">
                    @csrf
                    <input type="file" class="form-control" name="thing">
                    <br>
                    <input type="submit" class="btn btn-sm btn-block btn-danger" value="upload">
                </form>
            </div>
0 likes
3 replies
drewdan's avatar

This is what the client library is doing:

public function fetchAccessTokenWithRefreshToken($refreshToken = null)
  {
    if (null === $refreshToken) {
      if (!isset($this->token['refresh_token'])) {
        throw new LogicException(
            'refresh token must be passed in or set as part of setAccessToken'
        );
      }
      $refreshToken = $this->token['refresh_token'];

It is suggesting you are passing a null value into it. So, you need to check your config values are correct. I would suggest dumping out the value of $config('refreshToken') and seeing what it holds, as I think maybe they are wrong.

Please or to participate in this conversation.