nao-pon / flysystem-google-drive

Flysystem adapter for Google Drive
MIT License
351 stars 128 forks source link

Google Drive API V3 - Login required 401 Error #92

Open vinhnguyenlastmileworks opened 3 years ago

vinhnguyenlastmileworks commented 3 years ago

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.

PaolaRuby commented 3 years ago

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

rafatriolo commented 3 years ago

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.

raktim135 commented 2 years ago

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
PaolaRuby commented 2 years ago

@raktim135 maybe this package needs a PR like this https://github.com/masbug/flysystem-google-drive-ext/pull/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?

hassanshahzadaheer commented 2 years ago

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 👍🏽