tidyverse/googlesheets4

Error in `googlesheets4::gs4_auth()`:

Closed this issue · 5 comments

Where I try to connect through the browser:

googlesheets4::gs4_auth(email = 'arben@email.com')

I get the following error:

Error in googlesheets4::gs4_auth():
! Can't get Google credentials.
ℹ Are you running googlesheets4 in a non-interactive session? Consider:
• Call 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
Run rlang::last_error() to see where the error occurred.

Can I start the auth process from scratch? I am afraid I did something that impacted my usual auth process, namely through the browser.

Can you tell me more about the context? Are you in an interactive session? What IDE? Are you in a notebook, etc.

General troubleshooting tips:
https://gargle.r-lib.org/articles/troubleshooting.html

including how to do a hard reset by deleting your entire token cache.

Hi, sure!

  • I am in an interactive session
  • I am using RStudio on a mac
  • I am running the code through an R script

I tried running the following code:
gs4_deauth()

When I try to run:
sheet_id = gs4_get(URL)

Now I get the following error:
Error in gargle::response_process():
! Client error: (403) PERMISSION_DENIED
• Client does not have sufficient permission. This can happen
because the OAuth token does not have the right scopes, the
client doesn't have permission, or the API has not been enabled
for the client project.
• The caller does not have permission

There is no "gargle" folder in my "Cache" folder, so I cannot even delete the cache. The following path does not exist: "Library/Caches/gargle"

Thank you for your help!

I would take the error at face value.

  • Are you using your own oauth client or the built in one? If it's your own, have you enabled the Sheets API?
  • During the interactive browser oauth dance, was there a checkbox that needed to be checked to grant the app permission to work with Sheets? Did you check it?
  • Are you 100% sure you have auth'ed as a user with access to the Sheet in question?

Thank you for your answer. Just to provide some more context:

  • Initially, I wanted to connect to Google BigQuery and retrieve some data there. So, I run the following command:
    bq_auth(path = "key.json")

As soon as I ran that command, I got this error mentioned above:

Error in googlesheets4::gs4_auth():
! Can't get Google credentials.
ℹ Are you running googlesheets4 in a non-interactive session? Consider:
• Call 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
Run rlang::last_error() to see where the error occurred.

For some reason, this also impacted my access to Google sheets. Is there a way to force the browser oath dance again?

Anyway, to reply to your comments:

  • I am using a built in client. This client works for my colleague but doesn't work for me, so I assume it is not a client problem, otherwise it would work for me, too.
  • The thing I am not even prompted to do the browser oauth dance. However, it used to work fine up until a couple of days ago so I assume I did check that box.
  • I confirm that I have access to said sheet.

I came across this thread by searching for another issue I had with authenticating the package - and thought to leave you some comments @ArbenKqiku - perhaps they can be helpful.

First - judging by your last comment I think it might be that you mixed up some things ? Because you mention that you ran first a bq_auth() command which comes from the bigrquery package - but your follow up output mentions only gs4_ errors - which seems odd. Might be that you oversaw something ?

In any case - these are some things I found helpful in dealing with this problem. I also ran some commands quickly which opened a new browser tab where you are supposed to tick a box to allow the package to work with your google "stuff". I was too quick and have clicked the wrong things which led to errors.
I found the gargle:::cache_locate() function helpful (note the 3 colons there). For me it was the "usual" ~/Library/Caches/gargle --> so i went and deleted this dir, restarted R from scratch and ran the auth code again - this time clicked the box and all was fine.
Could it be that perhaps for some reason you have an "unusual" location of your cache dir so maybe by checking this you could locate it and delete it.
Anyways - hope it helps you solve your problem. Otherwise come back and comment here and maybe we can solve it together.