Hello Everyone,
I recently updated to gargle release 1.4.0 and encountered a problem that started for me with updates committed in release 1.2.1. After a number of tests I was able to see that my issue is specific to running requests on a virtual machine spun up with google cloud platform. Updates were made such that gargle would detect if it was being run on GCE and then the authentication would seem to force using service account credentials rather than the oauth2 user credentials.
In order to address the 1.2.1 issue I was able to run the following command before I initialized other tidyverse packages. Using googlesheets4 as a specific use case I would do the following steps to initialize
# Run this function to fix the hierarchy issue
gargle::cred_funs_add(credentials_user_oauth2 = credentials_user_oauth2)
# Reference oauth2 user credentials
googlesheets4::gs4_auth_configure(path = "path/to/my/credentials_google-oauth-client.json")
googlesheets4::gs4_auth(email = "CLIENT_EMAIL")
With the 1.4.0 release the first line fix I used to have now returns an error
Error in `gargle::cred_funs_add()`:
! This name already appears in the credential function registry:
✖ credentials_user_oauth2
Run `rlang::last_trace()` to see where the error occurred.
And whenever I attempt to access/edit something in googlesheets4 (or googledrive as well) I receive permission error (example below) which are the same as when I was being forced into the service account credentials.
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.
• Request had insufficient authentication scopes.
So just to clarify, the permission error isn't a surprise - I know the service account does not have access to the target files. My issue is trying to avoid being forced into using the service account on a GCE instance. Again, I was able to avoid it by previously running a gargle::cred_funs_add() command that is no longer working now
Thanks very much in advance for any help here