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
Problem with authentication with drive_auth #276
Comments
This sounds characteristic of a zombie process sitting on a port. Read this and try the remedies described there: https://gargle.r-lib.org/articles/auth-from-web.html#but-i-didnt-need-oob-yesterday |
|
yes, it was indeed the case. Thanks! |
|
although I killed the process running on the port 1410 multiple times, I am still getting the same error. The problem now is that when I run: the file .httr-oauth is not created anymore |
Current googledrive no longer defaults to caching in |
|
when I run gargle::gargle_oauth_sitrep() I get: then I run this: I tried also with googledrive::drive_auth(use_oob = TRUE) but the credentials are not stored. I am using rstudio server and this is the sessionInfo(): R version 3.6.0 (2019-04-26) Matrix products: default Random number generation: locale: attached base packages: other attached packages: loaded via a namespace (and not attached): |
All of this is consistent with never having completed a full auth sequence. The cache will be established the first time there is a token to put in it.
What exactly happens? |
|
so, how do I complete the full auth sequence? If I try to knit the Rmd file it stays still, as waiting for the authentication from the browser. If I run drive_auth(use_oob=TRUE), then I can run the full script but only manually. |
|
I don't know how to help until you give more detail. When I do oob auth, here's what I see: Now I'm sent to the browser to specify a Google user in a "Choose your account" page. I choose one. Then, on the next screen, I choose to "Allow" the Tidyverse API Packages to access my account. Then I get this screen. I copy that code, as it says, and go back to R. I paste it. I am now logged in: How is your experience different from this? |
|
It works only partially. Like for you after running I'm sent to the browser to specify a Google user in a "Choose your account" page. I choose one. Then, on the next screen, I choose to "Allow" the Tidyverse API Packages to access my account. And I copy and paste the code into the console in Studio. Then I am authenticated and I can get files from google drive into rstudio. However, if after I click on knit to run the whole Rmd file then the authentication is lost. |
|
In the code that is run as a cron job, you need to have drive_auth(email = “BLAH@gmail.com”), so we know which existing token to use. That prevents the attempt to interact with you for auth in a noninteractive session. |
|
do you mean to run once drive_auth(use_oob=TRUE) and after to paste in the code the following? I just tried but I get the same issue, the script does not remember the credentials |
|
No. Once, interactively, you do auth. That stores a token on your computer. In your code, which might run noninteractively, tell googledrive which already-existing token to use. |
|
This is not clear to me yet. What should I do to store the credentials so that the script find them when I knit a Rmd file? |
Please describe your exact evidence for this. I'm beginning to think this would be better off as a thread in https://community.rstudio.com. I don't think there's a bug. |
|
These are the full steps:
|........... | 18%
Is it possible that it is a problem of the package version with Rstudio server? I already posted it on rstudio community: |
|
Once you successfully authenticate once, interactively, can you show me the output of knitting an I do not understand why the token you obtain interactively, is not found and used when rendering the library(googledrive)
gargle::gargle_oauth_sitrep()
drive_auth(email = "BLAH@gmail.com")
drive_user() |
|
I tested the code in a clean environment in Rstudio cloud and the result is the same as before. First I run drive_auth(use_oob=TRUE) And then when I knit the Rmd file with the following code: library(googledrive) I get:
The same result if I knit the Rmd file with the following code: listfiles <- drive_ls() Error: Can't get Google credentials.
Maybe you can test it on your side with the following code in a new environment and check if you are able to knit a Rmd file: |
|
This is the first time you've mentioned RStudio Cloud. That is an important detail. What does |
|
RStudio Cloud is very project-based vs. user-based. So it could be a problem with the logic for establishing and finding a token cache. I.e. the cache is not getting established, which would explain why a non-interactive render does not have access to any previously acquired tokens. |
|
So you can also try the instructions in this vignette that describe how to specify the cache path yourself, i.e. to embed it in a project. https://gargle.r-lib.org/articles/non-interactive-auth.html#project-level-oauth-cache |
|
my working environment is an Rstudio server, not Rstudio cloud. Therefore I need to make it work on Rstudio server. Anyway, on Rstudio cloud, if I run gargle::gargle_oauth_sitrep() I get: |
|
I suggest you try the instructions above in which you take control of the cache location. |
|
I have done all of this successfully on RStudio Server myself now and have verified with others, internally, that it also works for them. Here's what getting the initial token looks like for me: > library(googledrive)
> packageVersion("googledrive")
[1] ‘1.0.0’
> packageVersion("gargle")
[1] ‘0.4.0’
> drive_auth(use_oob = TRUE)
Is it OK to cache OAuth access credentials in the folder '/usr/home/jenny/.R/gargle/gargle-oauth' between R sessions?
1: Yes
2: No
Selection: 1
Enter authorization code: abcdefghijklmnopqrstuvwxyzThen I have a #' ---
#' output: github_document
#' ---
library(googledrive)
drive_auth(email = "jenny@rstudio.com")
gargle::gargle_oauth_sitrep()And I can render it non-interactively like so: And it produces this Markdown: wtf.Rjenny library(googledrive)
drive_auth(email = "jenny@rstudio.com")
gargle::gargle_oauth_sitrep()So ... perhaps something is misconfigured with your RStudio Server or something odd about your personal configuration is getting in the way. |
|
I tested it on a new clean ubuntu server (18.10) and when I run the last part: I got the same error: Error: callr subprocess failed: Can't get Google credentials.
However, I made it work again by running just once: and by adding in the Rmd file: I wonder what happened because before it was working totally fine just by running once drive_auth(use_oob = TRUE) |

I have the same issue as in #274
and I posted the same issue here as well:
https://community.rstudio.com/t/problem-with-authentication-with-drive-auth-for-googledrive-library/41013
I have some code that it used to run correctly until one week ago but not when I try to get data from googledrive I get the following error:
createTcpServer: address already in use 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.
Therefore I run the following again:
drive_auth(use_oob=TRUE)
but when I restart the session or knit a rmd document then I get again the above error.
Then I run the following:
options(gargle_quiet = FALSE)
drive_auth(use_oob=TRUE)
and this is the result:
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
putting token into the cache
I also tried the same in Rstudio with a mac and the result is the same.
Do you have any suggestions how to solve it?
The text was updated successfully, but these errors were encountered: