tidyverse/googlesheets4

`gs4_auth` is now defaulting to OAuth instead of using a Service Account json

Closed this issue · 3 comments

Hi @jennybc,
Thank you for this pervasively useful package!
I'm not sure how I would include a reprex since this is related to behavior when using a service account json.

gs4_auth used to silently authenticate with a Service Account json when the path was passed to the path argument as follows:

googlesheets4::gs4_auth(path = "[path to service account json]")

However,
In recent updates to googlesheets4 or perhaps the underlying gargle functionality, the Service Account JSON is no longer being recognized and gs4_auth is now displaying the "Waiting for authentication in browser" message and opening the OAuth dialog in the browser.

Any ideas on what has changed and why SA JSON authentication is now failing?

This probably means that the service account token has become invalid or gone missing. I don't think it's a change in googlesheets4 or gargle, I think it's a change in your world.

Some troubleshooting ideas:
https://gargle.r-lib.org/articles/troubleshooting.html

Hi @jennybc,
Thank you for responding so soon!
I had considered this possibility prior to writing the post and so I disabled and re-enabled the service account and re-downloaded a JSON. The key attached to the JSON does not have an expiration date.

Thanks for the troubleshooting tips.
I implemented the gargle verbosity and came up with what's below. The HTTP 400 would seem to suggest that the request is malformed. Perhaps Google recently changed the request format?

gargle::with_gargle_verbosity("debug", googlesheets4::gs4_auth(path = "[my_token.json]"))
trying `token_fetch()`
trying `credentials_service_account()`
adding "userinfo.email" scope
Error caught by `token_fetch()`:
Bad Request (HTTP 400).
trying `credentials_external_account()`
aws.ec2metadata not installed; can't detect whether running on EC2 instance
trying `credentials_app_default()`
trying `credentials_gce()`
trying `credentials_byo_oauth()`
Error caught by `token_fetch()`:
inherits(token, "Token2.0") is not TRUE
trying `credentials_user_oauth2()`
Gargle2.0 initialize
attempt to access internal gargle data from: googlesheets4
adding "userinfo.email" scope
loading token from the cache
no matching token in the cache
initiating new token
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort

Hi @jennybc,
Third time's the charm I guess?
I deleted all the keys and recreated a new key and now it appears to be working again 🤷
Maybe I accidentally modified the other JSON somehow?

Anyway, thanks for your time and attention 🙏