tidyverse/googledrive

unable to generate Google autharization tokens in rstudioserver

naveenbussari opened this issue · 3 comments

Hi @jennybc
We are trying to generate Oauth tokens on Rstudio server to work on googledrive files using the following code.

options(gargle_oauth_client_type = "web")

googledrive::drive_auth(email = "bussari.naveen@olaelectric.com")

googlesheets4::gs4_auth(email = "bussari.naveen@olaelectric.com")

first we got the error createTcpServer: address already in use

Error in googledrivedrive_auth()°

I did this
9 17304

Now I re-run the above code.
It's generating the token and we are able to copy the authorization code.
Complete the Google auth process

But the console is stuck forever with 'Waiting for authentication in browser' and there's no 'Enter authorization code ' prompt.
Pasted Graphic 21

At the same time in the server,
image

we are using gargle 1.4.0 and tidyVerse 1.3.2

FYI we were facing similar issues earlier.
#425
#424

Regards
Naveen

It worked after including the line

options(httr_oob_default = TRUE)

Thanks

I'm glad you've got it working.

I'm curious though: on RStudio Server, gargle (which provide auth functionality for googledrive) should automatically detect that it should use an oauth client of "web" type and that it should use out-of-band auth. Are you setting these things explicitly for a reason? If not, I think perhaps you should try doing less and allow the auto detection to happen. But if this is in response to a failure of auto-detection, I'd be interested to learn more.

I revisited the issues linked above and now I remember. You do auth in an interactive RStudio session, but then later need that token to work in a cron job. So it makes more sense to me now why you might need to set these options. But I think this is more sensible than what you're currently doing (basically: be consistent about setting gargle options, not a mix of gargle and httr):

options(gargle_oob_default = TRUE, gargle_oauth_client_type = "web")