tidyverse / googlesheets4

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

gnutls_handshake() failed: An unexpected TLS packet was received. #265

Closed Deleetdk closed 2 years ago

Deleetdk commented 2 years ago

This bug appears sometimes. I can't figure out what it is due to exactly, but some kind of authentication failure, or expired token. I post it here because there seems to be no prior issue about this error for this package, but one can find it in many other places e.g. with git.

Not a reprex, but the bug will appear with this kind of code

>gs4_auth("your_email@gmail.com")
> uk = read_sheet("https://docs.google.com/spreadsheets/d/1ndPGvJSrdf722ccAUuhePsW3LiQaBSe6igxViTRWlkg/edit#gid=1403363505",
+                 sheet = "Per capita")
Auto-refreshing stale OAuth token.
Error in curl::curl_fetch_memory(url, handle = handle) : 
  gnutls_handshake() failed: An unexpected TLS packet was received.

In my case, since this document is public, one can deauth and then it works again:

> gs4_deauth()
> uk = read_sheet("https://docs.google.com/spreadsheets/d/1ndPGvJSrdf722ccAUuhePsW3LiQaBSe6igxViTRWlkg/edit#gid=1403363505",
+                 sheet = "Per capita")
✔ Reading from ukdata.
✔ Range ''Per capita''.

Restarting R fixes the issue, and one can use gs4_auth() followed by read_sheet() as normal.

jennybc commented 2 years ago

I don't think this is a googlesheets4 problem. I think it's coming from curl / the transport layer. Specifically, I don't think there's anything googlesheets4 can do to remediate it.

I think it's probably intermittent and that the deauth or restarting R is ?probably? not causally related to things working / not working.