r-lib / gmailr

Access the Gmail RESTful API from R.
https://gmailr.r-lib.org
Other
229 stars 56 forks source link

Stop requiring a configured oauth client prior to `token_fetch()` #186

Closed jennybc closed 1 year ago

jennybc commented 1 year ago

Fixes #160

The basic idea is to let token_fetch() fail for someone who wants the user flow AND who has failed to configure an OAuth client. Then, in the gm_auth() error message, try to provide enough info to help that user diagnose their problem.

Previously an OAuth client was required, unconditionally, prior to calling token_fetch(). The upside is that the user who wants the user flow gets an unequivocal early error message if they haven't configured a client. And this is by far the most common use case.

But the downside is that no other auth flow can work. No BYO token, no service account, no ADC, etc. None of those even need an OAuth client, but they are currently inaccessible because of the unconditional client check. So that has to change.

Here I remove the unconditional check for an OAuth client and, instead, insert specific advice in the gm_auth() error message.

While I was working on the message, I also added advice about setting options(gargle_verbosity = "debug").

This change also makes it easier to auth with the dev/testing credentials, which uses BYO token.