Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission difficulties through gs4_auth() and gs4_auth_configure() #310

Open
JustGottaCAT opened this issue Jan 2, 2024 · 2 comments
Open

Comments

@JustGottaCAT
Copy link

My company has an internal Google domain and I'm attempting to read a Google spreadsheet from it. I keep getting permission errors when I try to use gs4_auth() or gs4_auth_configure().

If I use gs4_auth() I am taken to the authorization screen, choose "Yes", and then get this error:
image

I allowed "Tidyverse API Packages" access via admin.google.com > Security > Access and data control > API Controls (for some reason there were 6 IDs). My company's domain is "Trusted and block-exempt". gs4_auth() still did not work.

I also tried generating an API key and client ID for the Google Sheets API and used that:

library(googlesheets4)
library(gargle)

google_client <- gargle_oauth_client_from_json(
path = 'path_to_Google_Sheets_client_ID_json_file.json',
name = 'Name of client ID in Google Cloud Console')

gs4_auth_configure(client = google_client, api_key = 'Google_Sheets_API_generated_key')

gs4_oauth_app()

<gargle_oauth_client>
name: Name of client ID in Google Cloud Console
id: Client ID in Google Cloud Console
secret: <REDACTED>
type: installed
redirect_uris: http://localhost

But I get a permission error when I actually try to read in a sheet:

read_sheet('sheet_ID')

Error in `gs4_get_impl_()`:
! 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

Eventually I would like this all done using encrypted service account credentials and would like to publish an Rmd with my code on our internal Posit Server, but I figure that is down the line if I can't even get the above to work.

@jennybc
Copy link
Member

jennybc commented Jan 4, 2024

the API has not been enabled for the client project

It's hard to say what's going wrong, but currently my money is on this ☝️

Is the Sheets API definitely enabled for your oauth client?

@dsteinberg20
Copy link

I'm having the exact same issue. How do I enable the sheets api in my oauth client?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants