Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

driv_auth and google colaboratory #284

Closed
jobdiogenes opened this issue Dec 10, 2019 · 6 comments
Closed

driv_auth and google colaboratory #284

jobdiogenes opened this issue Dec 10, 2019 · 6 comments

Comments

@jobdiogenes
Copy link

I'm trying to use googledrive and googlesheets4 in Google Colaboratory, but tips about drive_auth found in #276 or #274, did not solve.

Here is the Colab Notebook. Demo of use GoogleDrive with R in Google Colaboratory
that I'm testing.

The error is

trying token_fetch()
trying credentials_service_account()
Error: Argument 'txt' must be a JSON string, URL or file.
trying credentials_app_default()
trying credentials_gce()
trying credentials_byo_oauth()
Error: inherits(token, "Token2.0") is not TRUE
trying credentials_user_oauth2()
Gargle2.0 initialize
attempt from: googledrive
adding 'userinfo.email' scope
loading token from the cache
no matching token in the cache
Error: Can only use oob authentication in an interactive session
Error: Can't get Google credentials.
Are you running googledrive in a non-interactive session? Consider:

  • drive_deauth() to prevent the attempt to get credentials.
  • Call drive_auth() directly with all necessary specifics.

Traceback:

  1. drive_auth(use_oob = TRUE)

  2. stop("Can't get Google credentials.\n", "Are you running googledrive in a non-interactive session? Consider:\n",
    . " * drive_deauth() to prevent the attempt to get credentials.\n",
    . " * Call drive_auth() directly with all necessary specifics.\n",
    . call. = FALSE)

@jennybc
Copy link
Member

jennybc commented Dec 11, 2019

I've requested access to your Colab notebook from my RStudio email address. I'll take a look when I'm allowed.

@tingjhenjiang
Copy link

I'm trying to use googledrive and googlesheets4 in Google Colaboratory, but tips about drive_auth found in #276 or #274, did not solve.

Here is the Colab Notebook. Demo of use GoogleDrive with R in Google Colaboratory
that I'm testing.

The error is

trying token_fetch()
trying credentials_service_account()
Error: Argument 'txt' must be a JSON string, URL or file.
trying credentials_app_default()
trying credentials_gce()
trying credentials_byo_oauth()
Error: inherits(token, "Token2.0") is not TRUE
trying credentials_user_oauth2()
Gargle2.0 initialize
attempt from: googledrive
adding 'userinfo.email' scope
loading token from the cache
no matching token in the cache
Error: Can only use oob authentication in an interactive session
Error: Can't get Google credentials.
Are you running googledrive in a non-interactive session? Consider:

  • drive_deauth() to prevent the attempt to get credentials.
  • Call drive_auth() directly with all necessary specifics.

Traceback:

  1. drive_auth(use_oob = TRUE)
  2. stop("Can't get Google credentials.\n", "Are you running googledrive in a non-interactive session? Consider:\n",
    . " * drive_deauth() to prevent the attempt to get credentials.\n",
    . " * Call drive_auth() directly with all necessary specifics.\n",
    . call. = FALSE)

same issue here.

I've requested access to your Colab notebook from my RStudio email address. I'll take a look when I'm allowed.

Actually all you need is to save a copy of that ipynb file to your own drive, or you might just run it.

@jennybc
Copy link
Member

jennybc commented Dec 25, 2019

OK I've replicated all of this.

The fundamental problem seems to be that both interactive() and rlang::is_interactive() report FALSE on Google Colab. So out-of-band auth won't work. But you can also only use out-of band auth!

I'm going to have to consult with the Google Colab expert: @craigcitro.

Here's a notebook @craigcitro where I've replicated what the others say. By setting options manually, I can establish the gargle cache directory. But out-of-band auth still fails because a Colab R runtime appears to always report that we are not in an interactive session. So I'm wondering how auth could ever work 🤔

https://colab.research.google.com/drive/1pp8-7aFzvrGtnpwxHmzlTXADPGbw8_Rh

@terzieff
Copy link

I have the exact same issue, not in Colab, but running JupyterLab (Version 1.2.1) in my own environment on Google Kubernetes Engine.

interactive()
FALSE

rlang::is_interactive()
FALSE

sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS/LAPACK: /opt/conda/lib/libopenblasp-r0.3.7.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.6.2  IRdisplay_0.7.0 pbdZMQ_0.3-3    tools_3.6.2    
 [5] htmltools_0.4.0 pillar_1.4.3    base64enc_0.1-3 crayon_1.3.4   
 [9] Rcpp_1.0.4      uuid_0.1-4      IRkernel_1.1    jsonlite_1.6.1 
[13] digest_0.6.25   repr_1.1.0      rlang_0.4.5     evaluate_0.14  

I was able to make it work with the same hack @jobdiogenes posted here - r-lib/httr#634 (comment).

@jennybc
Copy link
Member

jennybc commented May 4, 2020

@terzieff You might want to subscribe to r-lib/gargle#130 which is about GKE and we are making progress.

@jennybc
Copy link
Member

jennybc commented May 4, 2020

Now tracking in r-lib/gargle#140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants