tidyverse / googlesheets4

Google Spreadsheets R API (reboot of the googlesheets package)
https://googlesheets4.tidyverse.org
Other
360 stars 53 forks source link

Timeout was reached: [sheets.googleapis.com] #250

Closed PhilGuerra closed 2 years ago

PhilGuerra commented 2 years ago

Hi love Googlesheets4!

Recently however I have been receiving a timeout error when attempting to read_sheet whereas previously my code had been working for several months flawlessly since I was forced to upgrade from Googlesheets to Googlesheets4 (v.1.0.0):

"Error in curl::curl_fetch_memory(url, handle = handle) : Timeout was reached: [sheets.googleapis.com] Connection timed out after 10001 milliseconds"

I am accessing via: library(googledrive) drive_auth_configure(api_key = "5XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXT") drive_api_key() options(gargle_oauth_email = "myname@myemail.com") options(gargle_oauth_email = TRUE)

...after which read_sheet results in the error above.

_Strangely readsheets works when automated with Cron. It is when I use RStudio and run code manually when I get the timeout error.

Any ideas? Do I need to refresh OAuth or tokens etc? All that stuff confuses me, and I was hoping to do it only one time in my life...

Thank you.

jennybc commented 2 years ago

This could be intermittent back luck or there could be something going on, e.g. with curl config or a proxy or ???, since you report a very different experience in the two settings.

But I can't help but point out this auth code seems rather confused.

Are you planning to auth with an API key or a user token? First the API key gets set ... but then immediately a user email is configured.

Why set the gargle_oauth_email option to an actual email but then immediately overwrite that with TRUE?

PhilGuerra commented 2 years ago

Hi Jennifer,

  1. I'm sure I've exposed my extreme n00bism with my code.
  2. The reason for the confusing code is actually due to..well... real confusion - because I don't understand the auth process like I did with original googlesheets.
  3. I need a) a way to auth but also b) not require user interaction for auth to occur as the script is designed to work on its own without any human interaction.
  4. The confused code was the only way I could manage to satisfy both requirements in #3 above.
  5. If you could kindly point to an example or vignette that satisfies both points in #3 above, I would very gladly study it and of course appreciate your help.
  6. But otherwise the main issue is the timeout with read_sheets when I run manually but not in cron.
  7. I would prefer not to make any changes to the auth code just yet for fear of breaking the code when cron runs the script due to my very bad understanding of how auth works.

Sincerely, Phillip

On Thu, Jan 20, 2022 at 10:14 AM Jennifer (Jenny) Bryan < @.***> wrote:

This could be intermittent back luck or there could be something going on, e.g. with curl config or a proxy or ???, since you report a very different experience in the two settings.

But I can't help but point out this auth code seems rather confused.

Are you planning to auth with an API or a user token? First the API key gets set ... but then immediately a user email is configured.

Why set the gargle_oauth_email option to an actual email but then immediately overwrite that with TRUE?

— Reply to this email directly, view it on GitHub https://github.com/tidyverse/googlesheets4/issues/250#issuecomment-1017670490, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJOFDOXZGEYATYW6TACKJM3UXAYFHANCNFSM5MKZLNZQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

jennybc commented 2 years ago

Various approaches for non-interactive auth are described here:

https://gargle.r-lib.org/articles/non-interactive-auth.html

Assuming you've got a valid, properly scoped googledrive token cached, from some successful interactive use, the auth code in the above example should get trimmed down to just this:

library(googledrive)
options(gargle_oauth_email = TRUE)

If you regularly work with googledrive AND multiple google identities, then you would want to specify the exact identity to use:

library(googledrive)
options(gargle_oauth_email = "myname@myemail.com")