Reputation: 121
I am currently running
library(googlesheets4)
sheets_auth()
dat=read_sheet("https://docs.google.com/spreadsheets/d/1R9XuH9Wej-p6HdkFGV2IsHuCmA9w0s7M3-jzE3S-Qrs/edit#gid=950673024", sheet="Summary", range=cell_rows(1:777))
and getting the following output.
Suitable tokens found in the cache, associated with these emails:
* [email protected]
* [email protected]
The first will be used.
Using an auto-discovered, cached token.
To suppress this message, modify your code or options to clearly consent to the use of a cached token.
See gargle's "Non-interactive auth" vignette for more details:
https://gargle.r-lib.org/articles/non-interactive-auth.html
The googlesheets4 package is using a cached token for [email protected].
>
> dat=read_sheet("https://docs.google.com/spreadsheets/d/1R9XuH9Wej-p6HdkFGV2IsHuCmA9w0s7M3-jzE3S-Qrs/edit#gid=950673024", sheet="Summary", range=cell_rows(1:777))
Error: 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
I am unsure if the issue is that it is forcing me to use the first email? Is it possible to change to the second token? But I am also confused about why I am no longer being asked to go into my google account to authenticate things?
Any ideas why this might be occurring? I am new to API's.
Upvotes: 10
Views: 9869
Reputation: 6659
For me the solution was:
googlesheets4::gs4_deauth()
googlesheets4::gs4_auth()
Then when you call the second one, DO NOT press 1 to select your email, instead press 0 to fetch a new token:
The googlesheets4 package is requesting access to your Google account.
Select a pre-authorised account or enter '0' to obtain a new token.
Press Esc/Ctrl + C to cancel.
1: [email protected]
Upvotes: 9
Reputation: 97
You can also 'Set GoogleSheet link to 'Anyone on the internet with this link can view' under the 'Share' button on the googlesheet page. Then:
googlesheets4::gs4_deauth()
CellROSConc <- read_sheet("https://docs.google.com/spreadsheets/d/1bxTIKTNfv-n3Y-JMJCOlt14Ec3e4tSdBQZg-HiuypOY/edit?usp=sharing")
Upvotes: -1
Reputation: 491
This could be because while you logged in using gs_auth
, you must have selected the wrong permissions. To re assign your permissions, first deauth using gs_deauth()
and then use gs_auth()
and in the next option, enter 0
in the Selection:
to re-initialize your accesses to google account.
Make sure in the browser window while assigning the permissions, you select the checkbox to read, write the spreadsheets.
Please comment if you're unable to do it.
Keep Coding!
Upvotes: 9
Reputation: 21
you can try with this
library(googlesheets4)
gs4_auth_configure(api_key = "A..............bMGBUA")
you should create a api key in credentials https://console.cloud.google.com/apis/credentials
i wait that it can help you
Upvotes: 2