Agnieszka
Agnieszka

Reputation: 81

Error trying to connect R to Googlesheet using package googlesheets4: Can't get Google credentials

I've a problem while trying to connect R with Googlesheet (package googlesheets4):

Error:Can't get Google credentials. Are you running googlesheets4 in a non-interactive session? Consider: *gs4_deauth() to prevent the attempt to get credentials. * Call gs4_auth() directly with all necessary specifics. See gargle's "Non-interactive auth" vignette for more details: https://gargle.r-lib.org/articles/non-interactive-auth.html

My R version is 4.0.3, the code was running properly when I've had version 3.5.3

Upvotes: 3

Views: 3048

Answers (2)

tchevrier
tchevrier

Reputation: 1171

I ran into this issue too.
I did not find any issues at all with the Gargle package, sorry.
Instead, what worked for me and should work for you was throwing the following into the console:

devtools::install_github("tidyverse/googlesheets4")

(it might work just fine with the "regular" version, but I did not get to test it, as many people complained online about versions being the potential issue... so I just went directly for the latest available one...)

library(googlesheets4)  
gs4_auth()

the console responds with:

Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.

You actually don't get to see the message at first, because the command opens up immediately your browser (google chrome in my case) and you are asked to grant access to your Google drive: simply click the unticked box and then the page changes again and you see a message "authentification granted, close this page to get back to R"...
Now in R, you see the message above, and everything now works as expected! :-)

Upvotes: 0

dhd
dhd

Reputation: 89

I just resolved the same error message problem that I was seeing from googlesheets4 and googledrive with the help of this advice from the garglepackage's troubleshooting page.

Package gargle is doing the behind the scenes work with G**gle's API and it seems that the problem is packages that gargle calls that might need to be updated for R versions >4.0.

To see if that is your case, change the gargle_verbosity argument from the default "info" to "debug" to see all the different attempts that gargle uses to provoke the authorisation process.

op <- options(gargle_verbosity = "debug")

For me, by re-running gs4_auth() or any similar function, I saw that the version of the curl package predated R version 4.0 and needed to be reinstalled.

After reinstalling curl, the browser log-in step worked but the function still could not generate / store a token because openssl also needed to be reinstalled for R versions >4.0.

Then I ran

options(op)

when I tired of gargle's verbosity.

Upvotes: 1

Related Questions