nao-pon/flysystem-google-drive

Google Drive API V3 - Login required 401 Error

vinhnguyenlastmileworks opened this issue · 5 comments

I was to connect my web app written in Laravel to connect with google drive. I use Flysystem Adapter.
Unfortunately After a period of use. it is showing 401 error? I have added client id, client secret , refersh token and folder id.

Google_Service_Exception { "error": { "errors": [ { "domain": "global", "reason": "required", "message": "Login Required", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Login Required" } }

I tried redoing the whole configuration on my account, but it doesn't seem to change anything.
can someone help me?

Thank all so much.

After a period of use

That means period of use on a long time executing script? because after 60 min needs a refresh I suppose

If you re-generate a valid token acording getting-your-refresh-token, maybe has a security config on google, also try another package to discard this package, masbug/flysystem-google-drive-ext have the same config

Hi there, I´ve followed these steps and so for so good. But after like 4 or 5 days this error : Google_Service_Exception { "error": { "errors": [ { "domain": "global", "reason": "required", "message": "Login Required", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Login Required" } } keeps showing, and I have to go through the refresh token again. Is there a more permanent solution.

Tks and best regards.

I have also faced the same issue in Laravel app and successfully solved it. Follow the steps below:

  1. Add GOOGLE_DRIVE_FOLDER_ID to .env and assign the value from your Google Console
  2. In app/filesystems.php, add 'accessToken' => env('GOOGLE_DRIVE_ACCESS_TOKEN'), to google drive config array.
  3. In GoolgeDriveServiceProvider.php set $client->setAccessToken($config['accessToken']);
  4. Test Now. Enjoy

@raktim135 maybe this package needs a PR like this masbug/flysystem-google-drive-ext#34,

Follow Google Docs to obtain your ClientId, ClientSecret & refreshToken in addition you can also check this easy-to-follow tutorial

also how you get the access token?

I have also faced the same issue in Laravel app and successfully solved it. Follow the steps below:

  1. Add GOOGLE_DRIVE_FOLDER_ID to .env and assign the value from your Google Console
  2. In app/filesystems.php, add 'accessToken' => env('GOOGLE_DRIVE_ACCESS_TOKEN'), to google drive config array.
  3. In GoolgeDriveServiceProvider.php set $client->setAccessToken($config['accessToken']);
  4. Test Now. Enjoy

thank you so much dear 👍🏽